Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
365:cda6938a8c6f | 366:68fd4de63eae |
---|---|
94 | 94 |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 TemporaryFile::TemporaryFile() | 99 static std::string CreateTemporaryPath(const char* extension) |
100 { | 100 { |
101 #if BOOST_HAS_FILESYSTEM_V3 == 1 | 101 #if BOOST_HAS_FILESYSTEM_V3 == 1 |
102 boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); | 102 boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); |
103 #elif defined(__linux__) | 103 #elif defined(__linux__) |
104 boost::filesystem::path tmpDir("/tmp"); | 104 boost::filesystem::path tmpDir("/tmp"); |
105 #else | 105 #else |
106 #error Support your platform here | 106 #error Support your platform here |
107 #endif | 107 #endif |
108 | 108 |
109 // We use UUID to create unique path to temporary files | 109 // We use UUID to create unique path to temporary files |
110 tmpDir /= "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); | 110 std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); |
111 path_ = tmpDir.string(); | 111 |
112 if (extension != NULL) | |
113 { | |
114 filename.append(extension); | |
115 } | |
116 | |
117 tmpDir /= filename; | |
118 return tmpDir.string(); | |
119 } | |
120 | |
121 | |
122 TemporaryFile::TemporaryFile() | |
123 { | |
124 path_ = CreateTemporaryPath(NULL); | |
125 } | |
126 | |
127 | |
128 TemporaryFile::TemporaryFile(const char* extension) | |
129 { | |
130 path_ = CreateTemporaryPath(extension); | |
112 } | 131 } |
113 | 132 |
114 | 133 |
115 TemporaryFile::~TemporaryFile() | 134 TemporaryFile::~TemporaryFile() |
116 { | 135 { |