]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_dir.hxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / misc / sg_dir.hxx
index 7befbc8cd99158b04e2aea2cad5457feafb67a05..336c2ee13bc0e6382e3d6b6894737687911e1ac1 100644 (file)
@@ -43,7 +43,15 @@ namespace simgear
   {
   public:
     Dir();
-      
+    ~Dir();
+    
+    /**
+     * when this directory object is destroyed, remove the corresponding
+     * diretory (and its contents) from the disk. Often used with temporary
+     * directories to ensure they are cleaned up.
+     */
+    void setRemoveOnDestroy();
+    
     static Dir current();
     
     /**
@@ -64,6 +72,11 @@ namespace simgear
     
     PathList children(int types = 0, const std::string& nameGlob = "") const;
     
+    /**
+     * test if the directory contains no children (except '.' and '..')
+     */
+    bool isEmpty() const;
+    
     SGPath file(const std::string& name) const;
     
     SGPath path() const
@@ -82,6 +95,12 @@ namespace simgear
      */
     bool remove(bool recursive = false);
     
+    /**
+     * remove our children but not us
+     */
+    bool removeChildren() const;
+    
+    
     /**
      * Check that the directory at the path exists (and is a directory!)
      */
@@ -93,6 +112,7 @@ namespace simgear
     Dir parent() const;
   private:
     mutable SGPath _path;
+    bool _removeOnDestroy;
   };
 } // of namespace simgear