Support disabling TmpPath auto cleanup
authorMichael Andres <ma@suse.de>
Mon, 26 Mar 2012 12:43:39 +0000 (14:43 +0200)
committerMichael Andres <ma@suse.de>
Mon, 26 Mar 2012 12:43:39 +0000 (14:43 +0200)
zypp/TmpPath.cc
zypp/TmpPath.h

index c338697..350382d 100644 (file)
@@ -82,6 +82,12 @@ namespace zypp {
         path() const
         { return _path; }
 
+        bool autoCleanup() const
+        { return( _flags & Autodelete ); }
+
+        void autoCleanup( bool yesno_r )
+       { _flags = yesno_r ? CtorDefault : NoOp; }
+
       private:
         Pathname _path;
         Flags    _flags;
@@ -156,6 +162,13 @@ namespace zypp {
       static Pathname p( getenv("ZYPPTMPDIR") ? getenv("ZYPPTMPDIR") : "/var/tmp" );
       return p;
     }
+
+    bool TmpPath::autoCleanup() const
+    { return _impl.get() ? _impl->autoCleanup() : false; }
+
+    void TmpPath::autoCleanup( bool yesno_r )
+    { if ( _impl.get() ) _impl->autoCleanup( yesno_r ); }
+
     ///////////////////////////////////////////////////////////////////
     //
     // CLASS NAME : TmpFile
index bab81e3..bb58f6c 100644 (file)
@@ -31,7 +31,8 @@ namespace zypp {
      * repesentation.
      *
      * When the last reference drops any file or directory located at the path
-     * passed to the ctor is deleted (recursivly in case of directories).
+     * passed to the ctor is deleted (recursivly in case of directories). This
+     * behavior can be canged by calling \ref autoCleanup.
      *
      * Principally serves as base class, but standalone usable.
      **/
@@ -73,6 +74,16 @@ namespace zypp {
         operator Pathname() const
         { return path(); }
 
+        /**
+        * Whether path is valid and deleted when the last reference drops.
+        */
+        bool autoCleanup() const;
+
+        /**
+        * Turn \ref autoCleanup on/off if path is valid.
+        */
+       void autoCleanup( bool yesno_r );
+
       public:
         /**
          * @return The default directory where temporary