diff Core/Toolbox.cpp @ 2017:08ce34cfacad

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 13 Jun 2016 15:49:10 +0200
parents 4dafe2a0d3ab
children 35ccba7adae9
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Mon Jun 13 15:26:20 2016 +0200
+++ b/Core/Toolbox.cpp	Mon Jun 13 15:49:10 2016 +0200
@@ -1480,5 +1480,30 @@
 
     return false;
   }
+
+
+  FILE* Toolbox::OpenFile(const std::string& path,
+                          FileMode mode)
+  {
+#if defined(_WIN32)
+    // TODO Deal with special characters by converting to the current locale
+#endif
+
+    const char* m;
+    switch (mode)
+    {
+      case FileMode_ReadBinary:
+        m = "rb";
+        break;
+
+      case FileMode_WriteBinary:
+        m = "wb";
+        break;
+
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+
+    return fopen(path.c_str(), m);
+  }
 }
-