Mercurial > hg > orthanc
changeset 6289:22ddac5de96e
SystemTooblox: added 2 methods to handle non ASCII-only path on Windows
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 28 Aug 2025 19:09:53 +0200 |
parents | 0fb251145172 |
children | 9ff90f4a5fd0 |
files | OrthancFramework/Sources/SystemToolbox.cpp OrthancFramework/Sources/SystemToolbox.h |
diffstat | 2 files changed, 26 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/SystemToolbox.cpp Thu Aug 28 15:19:41 2025 +0200 +++ b/OrthancFramework/Sources/SystemToolbox.cpp Thu Aug 28 19:09:53 2025 +0200 @@ -331,17 +331,25 @@ } } + void SystemToolbox::WriteFile(const void* content, size_t size, const std::string& path, bool callFsync) { + WriteFile(content, size, path, callFsync); + } + + void SystemToolbox::WriteFile(const void *content, + size_t size, + const boost::filesystem::path &path, + bool callFsync) + { try { - //boost::filesystem::ofstream f; boost::iostreams::stream<boost::iostreams::file_descriptor_sink> f; - + f.open(path, std::ofstream::out | std::ofstream::binary); if (!f.good()) { @@ -372,7 +380,7 @@ * systems: * https://github.com/boostorg/iostreams/blob/develop/include/boost/iostreams/detail/file_handle.hpp **/ - + #if defined(_WIN32) // https://docs.microsoft.com/fr-fr/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers success = (::FlushFileBuffers(f->handle()) != 0); @@ -687,7 +695,7 @@ } - bool SystemToolbox::IsRegularFile(const std::string& path) + bool SystemToolbox::IsRegularFile(const boost::filesystem::path& path) { try { @@ -706,6 +714,12 @@ } + bool SystemToolbox::IsRegularFile(const std::string& path) + { + return SystemToolbox::IsRegularFile(path); + } + + FILE* SystemToolbox::OpenFile(const std::string& path, FileMode mode) {
--- a/OrthancFramework/Sources/SystemToolbox.h Thu Aug 28 15:19:41 2025 +0200 +++ b/OrthancFramework/Sources/SystemToolbox.h Thu Aug 28 19:09:53 2025 +0200 @@ -44,6 +44,7 @@ #include <vector> #include <string> #include <stdint.h> +#include <boost/filesystem.hpp> namespace Orthanc { @@ -72,6 +73,11 @@ const std::string& path, bool callFsync); + static void WriteFile(const void *content, + size_t size, + const boost::filesystem::path &path, + bool callFsync); // this variant is mandatory to handle non ASCII-only path on Windows + static void WriteFile(const void* content, size_t size, const std::string& path); @@ -114,6 +120,8 @@ static bool IsRegularFile(const std::string& path); + static bool IsRegularFile(const boost::filesystem::path& path); // this variant is mandatory to handle non ASCII-only path on Windows + static FILE* OpenFile(const std::string& path, FileMode mode);