comparison Core/Toolbox.cpp @ 2087:e9e6ffbf0fd5

improved logging in FilesystemStorage
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Sep 2016 11:53:17 +0200
parents 14ce887a9182
children 0c09d1af22f3
comparison
equal deleted inserted replaced
2086:630606097798 2087:e9e6ffbf0fd5
310 void Toolbox::WriteFile(const void* content, 310 void Toolbox::WriteFile(const void* content,
311 size_t size, 311 size_t size,
312 const std::string& path) 312 const std::string& path)
313 { 313 {
314 boost::filesystem::ofstream f; 314 boost::filesystem::ofstream f;
315 f.open(path, std::ofstream::binary); 315 f.open(path, std::ofstream::out | std::ofstream::binary);
316 if (!f.good()) 316 if (!f.good())
317 { 317 {
318 throw OrthancException(ErrorCode_CannotWriteFile); 318 throw OrthancException(ErrorCode_CannotWriteFile);
319 } 319 }
320 320
321 if (size != 0) 321 if (size != 0)
322 { 322 {
323 f.write(reinterpret_cast<const char*>(content), size); 323 f.write(reinterpret_cast<const char*>(content), size);
324
325 if (!f.good())
326 {
327 f.close();
328 throw OrthancException(ErrorCode_FileStorageCannotWrite);
329 }
324 } 330 }
325 331
326 f.close(); 332 f.close();
327 } 333 }
328 #endif 334 #endif