diff Core/Toolbox.cpp @ 1911:7a05144cb919

author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 28 Jan 2016 17:07:22 +0100
parents b1291df2f780
children ff11ba08e5d0
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Fri Jan 15 17:31:00 2016 +0100
+++ b/Core/Toolbox.cpp	Thu Jan 28 17:07:22 2016 +0100
@@ -127,6 +127,7 @@
   }
 #endif
 
+
   void Toolbox::USleep(uint64_t microSeconds)
   {
 #if defined(_WIN32)
@@ -208,7 +209,7 @@
   void Toolbox::ReadFile(std::string& content,
                          const std::string& path) 
   {
-    if (!boost::filesystem::is_regular_file(path))
+    if (!IsRegularFile(path))
     {
       LOG(ERROR) << std::string("The path does not point to a regular file: ") << path;
       throw OrthancException(ErrorCode_RegularFileExpected);
@@ -268,7 +269,7 @@
   {
     if (boost::filesystem::exists(path))
     {
-      if (boost::filesystem::is_regular_file(path))
+      if (IsRegularFile(path))
       {
         boost::filesystem::remove(path);
       }
@@ -1382,5 +1383,26 @@
     return static_cast<int>(getpid());
 #endif
   }
+
+
+  bool Toolbox::IsRegularFile(const std::string& path)
+  {
+    namespace fs = boost::filesystem;
+
+    try
+    {
+      if (fs::exists(path))
+      {
+        fs::file_status status = fs::status(path);
+        return (status.type() == boost::filesystem::regular_file ||
+                status.type() == boost::filesystem::reparse_file);   // Fix BitBucket issue #11
+      }
+    }
+    catch (fs::filesystem_error&)
+    {
+    }
+
+    return false;
+  }
 }