diff Core/Uuid.cpp @ 366:68fd4de63eae

create temporary files file a given extension
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Feb 2013 09:32:53 +0100
parents fe180eae201d
children bdd72233b105
line wrap: on
line diff
--- a/Core/Uuid.cpp	Wed Feb 06 18:01:45 2013 +0100
+++ b/Core/Uuid.cpp	Thu Feb 07 09:32:53 2013 +0100
@@ -96,7 +96,7 @@
     }
 
 
-    TemporaryFile::TemporaryFile()
+    static std::string CreateTemporaryPath(const char* extension)
     {
 #if BOOST_HAS_FILESYSTEM_V3 == 1
       boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path();
@@ -107,8 +107,27 @@
 #endif
 
       // We use UUID to create unique path to temporary files
-      tmpDir /= "Orthanc-" + Orthanc::Toolbox::GenerateUuid();
-      path_ = tmpDir.string();
+      std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid();
+
+      if (extension != NULL)
+      {
+        filename.append(extension);
+      }
+
+      tmpDir /= filename;
+      return tmpDir.string();
+    }
+
+
+    TemporaryFile::TemporaryFile()
+    {
+      path_ = CreateTemporaryPath(NULL);
+    }
+
+
+    TemporaryFile::TemporaryFile(const char* extension)
+    {
+      path_ = CreateTemporaryPath(extension);
     }