# HG changeset patch # User Sebastien Jodogne # Date 1360225973 -3600 # Node ID 68fd4de63eae650d83dae7b94b59680930a26b95 # Parent cda6938a8c6ff0c0fbe73c9167ce07b9c8915f4b create temporary files file a given extension diff -r cda6938a8c6f -r 68fd4de63eae Core/Uuid.cpp --- 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); } diff -r cda6938a8c6f -r 68fd4de63eae Core/Uuid.h --- a/Core/Uuid.h Wed Feb 06 18:01:45 2013 +0100 +++ b/Core/Uuid.h Thu Feb 07 09:32:53 2013 +0100 @@ -59,6 +59,8 @@ public: TemporaryFile(); + TemporaryFile(const char* extension); + ~TemporaryFile(); const std::string& GetPath() const