Mercurial > hg > orthanc
changeset 1911:7a05144cb919
fix issue #11
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 28 Jan 2016 17:07:22 +0100 |
parents | c32a8fab4fc4 |
children | 2f415526fdcd |
files | Core/FileStorage/FilesystemStorage.cpp Core/HttpServer/FilesystemHttpHandler.cpp Core/Toolbox.cpp Core/Toolbox.h NEWS Plugins/Samples/ModalityWorklists/Plugin.cpp Plugins/Samples/ServeFolders/Plugin.cpp |
diffstat | 7 files changed, 47 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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 {
--- 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 += "<li><a href=\"" + h + "\">" + f + "</a></li>"; + } } s += " </ul>"; @@ -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
--- 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; + } }
--- 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); } }
--- 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)
--- 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());
--- 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 += " <li><a href=\"" + f + "\">" + f + "</a></li>\n";