Mercurial > hg > orthanc
comparison Core/Uuid.cpp @ 2140:aa4b8895cd23
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 16:12:47 +0100 |
parents | b1291df2f780 |
children | a260a8ad83f1 |
comparison
equal
deleted
inserted
replaced
2139:764c9157301b | 2140:aa4b8895cd23 |
---|---|
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 return IsUuid(str.substr(0, 36)); | 118 return IsUuid(str.substr(0, 36)); |
119 } | 119 } |
120 } | |
120 | 121 |
121 | 122 |
122 static std::string CreateTemporaryPath(const char* extension) | 123 static std::string CreateTemporaryPath(const char* extension) |
123 { | 124 { |
124 #if BOOST_HAS_FILESYSTEM_V3 == 1 | 125 #if BOOST_HAS_FILESYSTEM_V3 == 1 |
125 boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); | 126 boost::filesystem::path tmpDir = boost::filesystem::temp_directory_path(); |
126 #elif defined(__linux__) | 127 #elif defined(__linux__) |
127 boost::filesystem::path tmpDir("/tmp"); | 128 boost::filesystem::path tmpDir("/tmp"); |
128 #else | 129 #else |
129 #error Support your platform here | 130 #error Support your platform here |
130 #endif | 131 #endif |
131 | 132 |
132 // We use UUID to create unique path to temporary files | 133 // We use UUID to create unique path to temporary files |
133 std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); | 134 std::string filename = "Orthanc-" + Orthanc::Toolbox::GenerateUuid(); |
134 | 135 |
135 if (extension != NULL) | 136 if (extension != NULL) |
136 { | 137 { |
137 filename.append(extension); | 138 filename.append(extension); |
138 } | |
139 | |
140 tmpDir /= filename; | |
141 return tmpDir.string(); | |
142 } | 139 } |
143 | 140 |
144 | 141 tmpDir /= filename; |
145 TemporaryFile::TemporaryFile() : | 142 return tmpDir.string(); |
146 path_(CreateTemporaryPath(NULL)) | 143 } |
147 { | |
148 } | |
149 | 144 |
150 | 145 |
151 TemporaryFile::TemporaryFile(const char* extension) : | 146 #if ORTHANC_SANDBOXED == 0 |
152 path_(CreateTemporaryPath(extension)) | 147 TemporaryFile::TemporaryFile() : |
153 { | 148 path_(CreateTemporaryPath(NULL)) |
154 } | 149 { |
150 } | |
155 | 151 |
156 | 152 |
157 TemporaryFile::~TemporaryFile() | 153 TemporaryFile::TemporaryFile(const char* extension) : |
158 { | 154 path_(CreateTemporaryPath(extension)) |
159 boost::filesystem::remove(path_); | 155 { |
160 } | |
161 } | 156 } |
157 | |
158 | |
159 TemporaryFile::~TemporaryFile() | |
160 { | |
161 boost::filesystem::remove(path_); | |
162 } | |
163 #endif | |
162 } | 164 } |