diff Orthanc/Core/Toolbox.cpp @ 125:145e654112d6

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 28 Jan 2016 17:08:44 +0100
parents 3809121c3290
children e8cfda4c8a2f
line wrap: on
line diff
--- a/Orthanc/Core/Toolbox.cpp	Mon Jan 04 14:27:06 2016 +0100
+++ b/Orthanc/Core/Toolbox.cpp	Thu Jan 28 17:08:44 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;
+  }
 }