diff 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
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Fri Sep 16 09:18:35 2016 +0200
+++ b/Core/Toolbox.cpp	Fri Sep 16 11:53:17 2016 +0200
@@ -312,7 +312,7 @@
                           const std::string& path)
   {
     boost::filesystem::ofstream f;
-    f.open(path, std::ofstream::binary);
+    f.open(path, std::ofstream::out | std::ofstream::binary);
     if (!f.good())
     {
       throw OrthancException(ErrorCode_CannotWriteFile);
@@ -321,6 +321,12 @@
     if (size != 0)
     {
       f.write(reinterpret_cast<const char*>(content), size);
+
+      if (!f.good())
+      {
+        f.close();
+        throw OrthancException(ErrorCode_FileStorageCannotWrite);
+      }
     }
 
     f.close();