]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_dir.cxx
Use the original filename for the compressed image message.
[simgear.git] / simgear / misc / sg_dir.cxx
index 95f9949d9893e55800f69c706c27a5d9cb5caef2..8922b030e0d038ca506a46c85b094532f6173284 100644 (file)
@@ -47,22 +47,37 @@ using std::string;
 namespace simgear
 {
 
-Dir::Dir()
+Dir::Dir() :
+    _removeOnDestroy(false)
 {
 }
 
 Dir::Dir(const SGPath& path) :
-  _path(path)
+  _path(path),
+  _removeOnDestroy(false)
 {
     _path.set_cached(false); // disable caching, so create/remove work
 }
 
 Dir::Dir(const Dir& rel, const SGPath& relPath) :
-  _path(rel.file(relPath.str()))
+  _path(rel.file(relPath.str())),
+  _removeOnDestroy(false)
 {
     _path.set_cached(false); // disable caching, so create/remove work
 }
 
+Dir::~Dir()
+{
+    if (_removeOnDestroy) {
+        remove(true);
+    }
+}
+
+void Dir::setRemoveOnDestroy()
+{
+    _removeOnDestroy = true;
+}
+
 Dir Dir::current()
 {
 #ifdef _WIN32
@@ -79,7 +94,7 @@ Dir Dir::tempDir(const std::string& templ)
 {
 #ifdef HAVE_MKDTEMP
     char buf[1024];
-    char* tempPath = ::getenv("TMPDIR");
+    const char* tempPath = ::getenv("TMPDIR");
     if (!tempPath) {
         tempPath = "/tmp/";
     }