]> 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 707053ab27926dfa0e6daefe463ef75fb834ddc0..336c2ee13bc0e6382e3d6b6894737687911e1ac1 100644 (file)
@@ -42,6 +42,16 @@ namespace simgear
   class Dir
   {
   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();
     
     /**
@@ -62,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
@@ -80,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!)
      */
@@ -91,6 +112,7 @@ namespace simgear
     Dir parent() const;
   private:
     mutable SGPath _path;
+    bool _removeOnDestroy;
   };
 } // of namespace simgear