comparison Core/Toolbox.cpp @ 1588:b5bc87a7212d

OrthancPluginReadFile, OrthancPluginWriteFile
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Aug 2015 16:49:46 +0200
parents bd1889029cbb
children 334d3a92ed83
comparison
equal deleted inserted replaced
1587:d7e569640d09 1588:b5bc87a7212d
228 228
229 f.close(); 229 f.close();
230 } 230 }
231 231
232 232
233 void Toolbox::WriteFile(const std::string& content, 233 void Toolbox::WriteFile(const void* content,
234 size_t size,
234 const std::string& path) 235 const std::string& path)
235 { 236 {
236 boost::filesystem::ofstream f; 237 boost::filesystem::ofstream f;
237 f.open(path, std::ofstream::binary); 238 f.open(path, std::ofstream::binary);
238 if (!f.good()) 239 if (!f.good())
239 { 240 {
240 throw OrthancException(ErrorCode_CannotWriteFile); 241 throw OrthancException(ErrorCode_CannotWriteFile);
241 } 242 }
242 243
243 if (content.size() != 0) 244 if (size != 0)
244 { 245 {
245 f.write(content.c_str(), content.size()); 246 f.write(reinterpret_cast<const char*>(content), size);
246 } 247 }
247 248
248 f.close(); 249 f.close();
249 } 250 }
250 251
252
253 void Toolbox::WriteFile(const std::string& content,
254 const std::string& path)
255 {
256 WriteFile(content.size() > 0 ? content.c_str() : NULL,
257 content.size(), path);
258 }
251 259
252 260
253 void Toolbox::RemoveFile(const std::string& path) 261 void Toolbox::RemoveFile(const std::string& path)
254 { 262 {
255 if (boost::filesystem::exists(path)) 263 if (boost::filesystem::exists(path))