#include <simgear/math/sg_types.hxx>
#include <simgear/misc/sg_path.hxx>
+#ifdef _MSC_VER
+ typedef int mode_t;
+#endif
+
namespace simgear
{
typedef std::vector<SGPath> PathList;
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();
+
+ /**
+ * create a temporary directory, using the supplied name
+ */
+ static Dir tempDir(const std::string& templ);
+
Dir(const SGPath& path);
Dir(const Dir& rel, const SGPath& relPath);
PathList children(int types = 0, const std::string& nameGlob = "") const;
SGPath file(const std::string& name) const;
+
+ SGPath path() const
+ { return _path; }
+
+ /**
+ * create the directory (and any parents as required) with the
+ * request mode, or return failure
+ */
+ bool create(mode_t mode);
+
+ /**
+ * remove the directory.
+ * If recursive is true, contained files and directories are
+ * recursively removed
+ */
+ bool remove(bool recursive = false);
+
+ /**
+ * Check that the directory at the path exists (and is a directory!)
+ */
+ bool exists() const;
+
+ /**
+ * parent directory, if one exists
+ */
+ Dir parent() const;
private:
mutable SGPath _path;
+ bool _removeOnDestroy;
};
} // of namespace simgear