# HG changeset patch # User Sebastien Jodogne # Date 1453997242 -3600 # Node ID 7a05144cb9199cb4befcbf64c7b47232df3d4c02 # Parent c32a8fab4fc44fd45f10f971e0b120639ad59877 fix issue 11 diff -r c32a8fab4fc4 -r 7a05144cb919 Core/FileStorage/FilesystemStorage.cpp --- a/Core/FileStorage/FilesystemStorage.cpp Fri Jan 15 17:31:00 2016 +0100 +++ b/Core/FileStorage/FilesystemStorage.cpp Thu Jan 28 17:07:22 2016 +0100 @@ -165,7 +165,7 @@ { for (fs::recursive_directory_iterator current(root_), end; current != end ; ++current) { - if (fs::is_regular_file(current->status())) + if (Toolbox::IsRegularFile(current->path().string())) { try { diff -r c32a8fab4fc4 -r 7a05144cb919 Core/HttpServer/FilesystemHttpHandler.cpp --- a/Core/HttpServer/FilesystemHttpHandler.cpp Fri Jan 15 17:31:00 2016 +0100 +++ b/Core/HttpServer/FilesystemHttpHandler.cpp Thu Jan 28 17:07:22 2016 +0100 @@ -95,8 +95,10 @@ #endif std::string h = Toolbox::FlattenUri(uri) + "/" + f; - if (fs::is_regular_file(it->status())) + if (Toolbox::IsRegularFile(it->path().string())) + { s += "
  • " + f + "
  • "; + } } s += " "; @@ -156,7 +158,7 @@ p /= uri[i]; } - if (fs::exists(p) && fs::is_regular_file(p)) + if (Toolbox::IsRegularFile(p.string())) { FilesystemHttpSender sender(p); output.Answer(sender); // TODO COMPRESSION diff -r c32a8fab4fc4 -r 7a05144cb919 Core/Toolbox.cpp --- 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(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; + } } diff -r c32a8fab4fc4 -r 7a05144cb919 Core/Toolbox.h --- a/Core/Toolbox.h Fri Jan 15 17:31:00 2016 +0100 +++ b/Core/Toolbox.h Thu Jan 28 17:07:22 2016 +0100 @@ -190,5 +190,7 @@ const std::string& prefix); int GetProcessId(); + + bool IsRegularFile(const std::string& path); } } diff -r c32a8fab4fc4 -r 7a05144cb919 NEWS --- a/NEWS Fri Jan 15 17:31:00 2016 +0100 +++ b/NEWS Thu Jan 28 17:07:22 2016 +0100 @@ -7,6 +7,7 @@ * Huge speedup if decoding the family of JPEG transfer syntaxes * Refactoring leading to speedups with custom image decoders (including Web viewer plugin) * Support decoding of RLE Lossless transfer syntax +* Fix issue 11 (is_regular_file() fails for FILE_ATTRIBUTE_REPARSE_POINT) Version 1.0.0 (2015/12/15) diff -r c32a8fab4fc4 -r 7a05144cb919 Plugins/Samples/ModalityWorklists/Plugin.cpp --- a/Plugins/Samples/ModalityWorklists/Plugin.cpp Fri Jan 15 17:31:00 2016 +0100 +++ b/Plugins/Samples/ModalityWorklists/Plugin.cpp Thu Jan 28 17:07:22 2016 +0100 @@ -124,6 +124,8 @@ const char* remoteAet, const char* calledAet) { + namespace fs = boost::filesystem; + Json::Value json; if (!GetQueryDicom(json, query)) @@ -137,16 +139,19 @@ OrthancPluginLogInfo(context_, msg.c_str()); } - boost::filesystem::path source(folder_); - boost::filesystem::directory_iterator end; + fs::path source(folder_); + fs::directory_iterator end; try { - for (boost::filesystem::directory_iterator it(source); it != end; ++it) + for (fs::directory_iterator it(source); it != end; ++it) { - if (is_regular_file(it->status())) + fs::file_type type(it->status().type()); + + if (type == fs::regular_file || + type == fs::reparse_file) // cf. BitBucket issue #11 { - std::string extension = boost::filesystem::extension(it->path()); + std::string extension = fs::extension(it->path()); ToLowerCase(extension); if (extension == ".wl") @@ -161,7 +166,7 @@ } } } - catch (boost::filesystem::filesystem_error&) + catch (fs::filesystem_error&) { std::string description = std::string("Inexistent folder while scanning for worklists: ") + source.string(); OrthancPluginLogError(context_, description.c_str()); diff -r c32a8fab4fc4 -r 7a05144cb919 Plugins/Samples/ServeFolders/Plugin.cpp --- a/Plugins/Samples/ServeFolders/Plugin.cpp Fri Jan 15 17:31:00 2016 +0100 +++ b/Plugins/Samples/ServeFolders/Plugin.cpp Thu Jan 28 17:07:22 2016 +0100 @@ -198,7 +198,10 @@ for (fs::directory_iterator it(parent) ; it != end; ++it) { - if (fs::is_regular_file(it->status())) + fs::file_type type = it->status().type(); + + if (type == fs::regular_file || + type == fs::reparse_file) // cf. BitBucket issue #11 { std::string f = it->path().filename().string(); s += "
  • " + f + "
  • \n";