changeset 6358:aa4558c0529e

cleaning up SystemToolbox to only keep boost::filesystem::path instead of strings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 29 Oct 2025 22:20:23 +0100
parents 0d5e5d9df39d
children 382f8665dbe0
files OrthancFramework/Sources/DicomNetworking/DicomServer.cpp OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp OrthancFramework/Sources/Images/Font.cpp OrthancFramework/Sources/Images/Font.h OrthancFramework/Sources/Images/FontRegistry.cpp OrthancFramework/Sources/Images/FontRegistry.h OrthancFramework/Sources/Logging.cpp OrthancFramework/Sources/SystemToolbox.cpp OrthancFramework/Sources/SystemToolbox.h OrthancFramework/Sources/Toolbox.cpp OrthancFramework/UnitTestsSources/DicomMapTests.cpp OrthancFramework/UnitTestsSources/FrameworkTests.cpp OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp OrthancFramework/UnitTestsSources/ImageTests.cpp OrthancServer/CMakeLists.txt OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Plugins/Samples/AdoptDicomInstance/Plugin.cpp OrthancServer/Plugins/Samples/ConnectivityChecks/Plugin.cpp OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp OrthancServer/Plugins/Samples/ServeFolders/CMakeLists.txt OrthancServer/Plugins/Samples/ServeFolders/OrthancFrameworkDependencies.cpp OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp OrthancServer/Resources/Samples/Tools/RecoverCompressedFile.cpp OrthancServer/Sources/EmbeddedResourceHttpHandler.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/main.cpp
diffstat 27 files changed, 207 insertions(+), 314 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomNetworking/DicomServer.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/DicomNetworking/DicomServer.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -538,12 +538,12 @@
                                "No path to the private key for the default DICOM TLS certificate was provided");
       }
       
-      if (!SystemToolbox::IsRegularFile(privateKeyPath))
+      if (!SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(privateKeyPath)))
       {
         throw OrthancException(ErrorCode_InexistentFile, "Inexistent file: " + privateKeyPath);
       }
 
-      if (!SystemToolbox::IsRegularFile(certificatePath))
+      if (!SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(certificatePath)))
       {
         throw OrthancException(ErrorCode_InexistentFile, "Inexistent file: " + certificatePath);
       }
@@ -576,7 +576,7 @@
     {
       CLOG(INFO, DICOM) << "Setting the trusted certificates for DICOM SCP connections: " << path;
 
-      if (!SystemToolbox::IsRegularFile(path))
+      if (!SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(path)))
       {
         throw OrthancException(ErrorCode_InexistentFile, "Inexistent file: " + path);
       }
--- a/OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/FileStorage/FilesystemStorage.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -195,7 +195,7 @@
               << "\" content type";
 
     std::string content;
-    SystemToolbox::ReadFile(content, GetPath(uuid).string());
+    SystemToolbox::ReadFile(content, GetPath(uuid));
 
     LOG(INFO) << "Read attachment \"" << uuid << "\" (" << timer.GetHumanTransferSpeed(true, content.size()) << ")";
 
@@ -239,7 +239,7 @@
     {
       for (fs::recursive_directory_iterator current(root_), end; current != end ; ++current)
       {
-        if (SystemToolbox::IsRegularFile(current->path().string()))
+        if (SystemToolbox::IsRegularFile(current->path()))
         {
           try
           {
--- a/OrthancFramework/Sources/Images/Font.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Images/Font.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -142,7 +142,7 @@
 
 
 #if ORTHANC_SANDBOXED == 0
-  void Font::LoadFromFile(const std::string& path)
+  void Font::LoadFromFile(const boost::filesystem::path& path)
   {
     std::string font;
     SystemToolbox::ReadFile(font, path);
--- a/OrthancFramework/Sources/Images/Font.h	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Images/Font.h	Wed Oct 29 22:20:23 2025 +0100
@@ -33,6 +33,11 @@
 #include <map>
 #include <boost/noncopyable.hpp>
 
+#if ORTHANC_SANDBOXED == 0
+#  include <boost/filesystem.hpp>
+#endif
+
+
 namespace Orthanc
 {
   class ORTHANC_PUBLIC Font : public boost::noncopyable
@@ -74,7 +79,7 @@
     void LoadFromMemory(const std::string& font);
 
 #if ORTHANC_SANDBOXED == 0
-    void LoadFromFile(const std::string& path);
+    void LoadFromFile(const boost::filesystem::path& path);
 #endif
 
     const std::string& GetName() const;
--- a/OrthancFramework/Sources/Images/FontRegistry.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Images/FontRegistry.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -49,7 +49,7 @@
 
 
 #if ORTHANC_SANDBOXED == 0
-  void FontRegistry::AddFromFile(const std::string& path)
+  void FontRegistry::AddFromFile(const boost::filesystem::path& path)
   {
     std::unique_ptr<Font> f(new Font);
     f->LoadFromFile(path);
--- a/OrthancFramework/Sources/Images/FontRegistry.h	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Images/FontRegistry.h	Wed Oct 29 22:20:23 2025 +0100
@@ -41,7 +41,7 @@
     void AddFromMemory(const std::string& font);
 
 #if ORTHANC_SANDBOXED == 0
-    void AddFromFile(const std::string& path);
+    void AddFromFile(const boost::filesystem::path& path);
 #endif
 
     size_t GetSize() const;
--- a/OrthancFramework/Sources/Logging.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Logging.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -600,7 +600,7 @@
       **/
 
       boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
-      boost::filesystem::path root(directory);
+      boost::filesystem::path root(SystemToolbox::PathFromUtf8(directory));
       boost::filesystem::path exe(SystemToolbox::GetPathToExecutable());
       
       if (!boost::filesystem::exists(root) ||
--- a/OrthancFramework/Sources/SystemToolbox.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/SystemToolbox.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -268,36 +268,6 @@
     }
   }
 
-  void SystemToolbox::ReadFile(std::string &content, 
-                               const std::string& path, 
-                               bool log) 
-  {
-    ReadFile(content, PathFromUtf8(path), log);
-  }
-
-  void SystemToolbox::ReadFile(std::string& content, const boost::filesystem::path& path)
-  { 
-    ReadFile(content, path, true /* log */);
-  }
-
-
-  void SystemToolbox::ReadFile(std::string &content, const std::string &path)
-  {
-    ReadFile(content, PathFromUtf8(path), true /* log */);
-  }
-
-  void SystemToolbox::ReadFile(std::string &content, const char* path) 
-  { 
-    ReadFile(content, std::string(path)); 
-   }
-
-  bool SystemToolbox::ReadHeader(std::string& header, 
-                                 const std::string& path, 
-                                 size_t headerSize)
-  {
-    return ReadHeader(header, PathFromUtf8(path), headerSize);
-  }
-
 
   bool SystemToolbox::ReadHeader(std::string& header,
                                  const boost::filesystem::path& path,
@@ -355,18 +325,9 @@
   }
 
   
-
-  void SystemToolbox::WriteFile(const void* content,
-                                size_t size,
-                                const std::string& path,
-                                bool callFsync)
-  {
-    WriteFile(content, size, PathFromUtf8(path), callFsync);
-  }
-
   void SystemToolbox::WriteFile(const void *content, 
                                 size_t size, 
-                                const boost::filesystem::path &path, 
+                                const boost::filesystem::path& path,
                                 bool callFsync)
   {
     try
@@ -432,35 +393,7 @@
   }
 
 
-  void SystemToolbox::WriteFile(const void *content, size_t size, const std::string &path)
-  {
-    WriteFile(content, size, path, false /* don't automatically call fsync */);
-  }
-
-
   void SystemToolbox::WriteFile(const std::string& content,
-                                const std::string& path,
-                                bool callFsync)
-  {
-    WriteFile(content.size() > 0 ? content.c_str() : NULL,
-              content.size(), path, callFsync);
-  }
-
-  void SystemToolbox::WriteFile(const std::string &content, 
-                                const boost::filesystem::path& path, 
-                                bool callFsync) 
-  { 
-    WriteFile(content.size() > 0 ? content.c_str() : NULL, 
-              content.size(), path, callFsync); 
-  }
-
-  void SystemToolbox::WriteFile(const std::string &content, const std::string &path)
-  {
-    WriteFile(content, path, false /* don't automatically call fsync */);
-  }
-
-  
-  void SystemToolbox::WriteFile(const std::string &content, 
                                 const boost::filesystem::path& path) 
   { 
     WriteFile(content.size() > 0 ? content.c_str() : NULL, 
@@ -468,11 +401,6 @@
   }
 
 
-  void SystemToolbox::RemoveFile(const std::string& path)
-  {
-    RemoveFile(SystemToolbox::PathFromUtf8(path));
-  }
-
   void SystemToolbox::RemoveFile(const boost::filesystem::path& path)
   {
     if (boost::filesystem::exists(path))
@@ -488,10 +416,6 @@
     }
   }
 
-  uint64_t SystemToolbox::GetFileSize(const std::string &path) 
-  {
-    return GetFileSize(PathFromUtf8(path));
-  }
 
   uint64_t SystemToolbox::GetFileSize(const boost::filesystem::path& path)
   {
@@ -509,6 +433,7 @@
     }
   }
 
+
 #if ORTHANC_ENABLE_MD5 == 1
   void SystemToolbox::ComputeStreamMD5(std::string& result,
                                        std::istream& inputStream)
@@ -533,13 +458,6 @@
   }
   
 
-  void SystemToolbox::ComputeFileMD5(std::string& result, 
-                                     const std::string& path) 
-  { 
-    return ComputeFileMD5(result, PathFromUtf8(path));
-  }
-
-
   void SystemToolbox::ComputeFileMD5(std::string& result,
                                      const boost::filesystem::path& path)
   {
@@ -554,12 +472,9 @@
     ComputeStreamMD5(result, fileStream);
   }
 
-  bool SystemToolbox::CompareFilesMD5(const std::string &path1, const std::string &path2) 
-  { 
-    return CompareFilesMD5(PathFromUtf8(path1), PathFromUtf8(path2));
-  }
 
-  bool SystemToolbox::CompareFilesMD5(const boost::filesystem::path& path1, const boost::filesystem::path &path2)
+  bool SystemToolbox::CompareFilesMD5(const boost::filesystem::path& path1,
+                                      const boost::filesystem::path& path2)
   {
     if (GetFileSize(path1) != GetFileSize(path2))
     {
@@ -578,11 +493,6 @@
 #endif
 
 
-  void SystemToolbox::MakeDirectory(const std::string& path)
-  {
-    MakeDirectory(PathFromUtf8(path));
-  }
-
   void SystemToolbox::MakeDirectory(const boost::filesystem::path& path)
   {
     if (boost::filesystem::exists(path))
@@ -602,12 +512,6 @@
   }
 
 
-  bool SystemToolbox::IsExistingFile(const std::string& path)
-  {
-    return boost::filesystem::exists(path);
-  }
-
-
 #if defined(_WIN32)
   static std::string GetPathToExecutableInternal()
   {
@@ -681,7 +585,7 @@
 
 
 #ifdef _WIN32
-  std::wstring SystemToolbox::Utf8ToWString(const std::string &str)
+  std::wstring SystemToolbox::Utf8ToWString(const std::string& str)
   {
     if (str.empty())
     {
@@ -728,16 +632,16 @@
   }
 #endif
 
-    boost::filesystem::path SystemToolbox::PathFromUtf8(const std::string &utf8)
+  boost::filesystem::path SystemToolbox::PathFromUtf8(const std::string& utf8)
   {
 #if defined(_WIN32) && !defined(__MINGW32__)  // non-ASCII paths are not supported when building with MinGW
-return boost::filesystem::path(Utf8ToWString(utf8));
+    return boost::filesystem::path(Utf8ToWString(utf8));
 #else
     return boost::filesystem::path(utf8); // POSIX: std::string is UTF-8
 #endif
   }
 
-  std::string SystemToolbox::PathToUtf8(const boost::filesystem::path &p)
+  std::string SystemToolbox::PathToUtf8(const boost::filesystem::path& p)
   {
 #if defined(_WIN32) && !defined(__MINGW32__)  // non-ASCII paths are not supported when building with MinGW
     return WStringToUtf8(p.wstring());
@@ -746,17 +650,18 @@
 #endif
   }
 
-  std::string SystemToolbox::GetPathToExecutable()
+
+  boost::filesystem::path SystemToolbox::GetPathToExecutable()
   {
-    boost::filesystem::path p(GetPathToExecutableInternal());
-    return boost::filesystem::absolute(p).string();
+    boost::filesystem::path p(PathFromUtf8(GetPathToExecutableInternal()));
+    return boost::filesystem::absolute(p);
   }
 
 
-  std::string SystemToolbox::GetDirectoryOfExecutable()
+  boost::filesystem::path SystemToolbox::GetDirectoryOfExecutable()
   {
-    boost::filesystem::path p(GetPathToExecutableInternal());
-    return boost::filesystem::absolute(p.parent_path()).string();
+    boost::filesystem::path p(PathFromUtf8(GetPathToExecutableInternal()));
+    return boost::filesystem::absolute(p.parent_path());
   }
 
 
@@ -842,18 +747,6 @@
   }
 
 
-  bool SystemToolbox::IsRegularFile(const std::string& path)
-  { 
-    return IsRegularFile(PathFromUtf8(path));
-  }
-
-
-  FILE *SystemToolbox::OpenFile(const std::string &path, 
-                                FileMode mode)
-  {
-    return OpenFile(PathFromUtf8(path), mode);
-  }
-  
   FILE* SystemToolbox::OpenFile(const boost::filesystem::path& path,
                                 FileMode mode)
   {
@@ -994,11 +887,6 @@
     return false;
   }
 
-  MimeType SystemToolbox::AutodetectMimeType(const std::string &path) 
-  { 
-    return AutodetectMimeType(PathFromUtf8(path));
-  }
-
 
   MimeType SystemToolbox::AutodetectMimeType(const boost::filesystem::path& path)
   {
@@ -1166,16 +1054,6 @@
   }
 
 
-  void SystemToolbox::ReadFileRange(std::string &content, 
-                                    const std::string &path,
-                                    uint64_t start, // Inclusive
-                                    uint64_t end, // Exclusive
-                                    bool throwIfOverflow)
-  {
-    ReadFileRange(content, SystemToolbox::PathFromUtf8(path), start, end, throwIfOverflow);
-  }
-
-
   void SystemToolbox::ReadFileRange(std::string& content,                              
                                     const boost::filesystem::path& path,
                                     uint64_t start,  // Inclusive
--- a/OrthancFramework/Sources/SystemToolbox.h	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/SystemToolbox.h	Wed Oct 29 22:20:23 2025 +0100
@@ -46,6 +46,9 @@
 #include <stdint.h>
 #include <boost/filesystem.hpp>
 
+// Note: The use of "boost::filesystem::path" is mandatory to handle
+// non ASCII-only path on Windows
+
 namespace Orthanc
 {
   class ORTHANC_PUBLIC SystemToolbox
@@ -58,121 +61,65 @@
     static ServerBarrierEvent ServerBarrier();
 
     static void ReadFile(std::string& content,
-                         const std::string& path,
-                         bool log);
-    
-    static void ReadFile(std::string &content, 
                          const boost::filesystem::path& path, 
                          bool log);
 
-    static void ReadFile(std::string &content, 
-                         const char* path);
-
-    static void ReadFile(std::string& content,
-                         const std::string& path);
-
-    static void ReadFile(std::string &content, 
-                         const boost::filesystem::path& path);
+    static inline void ReadFile(std::string& content,
+                                const boost::filesystem::path& path)
+    {
+      ReadFile(content, path, true /* log */);
+    }
 
     static bool ReadHeader(std::string& header,
-                           const std::string& path,
+                           const boost::filesystem::path& path,
                            size_t headerSize);
 
-   static bool ReadHeader(std::string &header, 
-                          const boost::filesystem::path& path, 
-                          size_t headerSize);
-
     static void WriteFile(const void* content,
                           size_t size,
-                          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);
-
-    static void WriteFile(const std::string& content,
-                          const std::string& path,
+                          const boost::filesystem::path& path,
                           bool callFsync);
 
     static void WriteFile(const std::string& content,
-                          const std::string& path);
-
-    static void WriteFile(const std::string &content, 
                           const boost::filesystem::path& path);
 
-    static void WriteFile(const std::string &content, 
-                          const boost::filesystem::path& path, 
-                          bool callFsync);
-
-    static void RemoveFile(const std::string& path);
-
     static void RemoveFile(const boost::filesystem::path& path);
 
-    static uint64_t GetFileSize(const std::string& path);
-
-    static uint64_t GetFileSize(const boost::filesystem::path &path);  // this variant is mandatory to handle non ASCII-only path on Windows
+    static uint64_t GetFileSize(const boost::filesystem::path& path);
 
 #if ORTHANC_ENABLE_MD5 == 1
     static void ComputeStreamMD5(std::string& result,
                                  std::istream& stream);
 
     static void ComputeFileMD5(std::string& result,
-                               const std::string& path);
-
-    static void ComputeFileMD5(std::string &result, 
-                               const boost::filesystem::path& path);  // this variant is mandatory to handle non ASCII-only path on Windows
+                               const boost::filesystem::path& path);
 
-    // returns true if file have the same MD5
-    static bool CompareFilesMD5(const std::string& path1,
-                                const std::string& path2); 
-
+    // Returns true if the two files have the same MD5
     static bool CompareFilesMD5(const boost::filesystem::path& path1, 
-                                const boost::filesystem::path& path2);  // this variant is mandatory to handle non ASCII-only path on Windows
+                                const boost::filesystem::path& path2);
 #endif
 
-    static void MakeDirectory(const std::string& path);
-
     static void MakeDirectory(const boost::filesystem::path& path);
 
-    static bool IsExistingFile(const std::string& path);
+    static boost::filesystem::path GetPathToExecutable();
 
-    static std::string GetPathToExecutable();
-
-    static std::string GetDirectoryOfExecutable();
+    static boost::filesystem::path GetDirectoryOfExecutable();
 
     static void ExecuteSystemCommand(const std::string& command,
                                      const std::vector<std::string>& arguments);
 
     static int GetProcessId();
 
-    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 bool IsRegularFile(const boost::filesystem::path& path);
 
-    static FILE* OpenFile(const std::string& path,
-                          FileMode mode);
-
-    static FILE* OpenFile(const boost::filesystem::path& path, 
+    static FILE* OpenFile(const boost::filesystem::path& path,
                           FileMode mode);
 
-    static MimeType AutodetectMimeType(const char* path)  // used only in Unit Tests
-    { 
-      return AutodetectMimeType(std::string(path));
-    }
+    static MimeType AutodetectMimeType(const boost::filesystem::path& path);
 
-    static MimeType AutodetectMimeType(const std::string &path);
-
-    static MimeType AutodetectMimeType(const boost::filesystem::path &path);
+    // This conversion is mandatory to handle non ASCII-only path on Windows
+    static boost::filesystem::path PathFromUtf8(const std::string& utf8);
 
-    static boost::filesystem::path PathFromUtf8(const std::string &utf8);
-
-    static std::string PathToUtf8(const boost::filesystem::path &p);
+    static std::string PathToUtf8(const boost::filesystem::path& p);
 
     static std::string GetNowIsoString(bool utc);
 
@@ -191,13 +138,7 @@
     static boost::filesystem::path InterpretRelativePath(const boost::filesystem::path& baseDirectory,
                                                          const std::string& relativePath);
 
-    static void ReadFileRange(std::string& content,                              
-                              const std::string& path,
-                              uint64_t start,  // Inclusive
-                              uint64_t end,    // Exclusive
-                              bool throwIfOverflow);
-
-    static void ReadFileRange(std::string &content, 
+    static void ReadFileRange(std::string& content,
                               const boost::filesystem::path& path,
                               uint64_t start, // Inclusive
                               uint64_t end, // Exclusive
@@ -206,9 +147,9 @@
     static void GetMacAddresses(std::set<std::string>& target);
 
 #ifdef _WIN32
-    static std::wstring Utf8ToWString(const std::string &str);
+    static std::wstring Utf8ToWString(const std::string& str);
 
-    static std::string WStringToUtf8(const std::wstring &wstr);
+    static std::string WStringToUtf8(const std::wstring& wstr);
 
     static std::wstring WStringFromCharPtr(const char *wstr);
 #endif
--- a/OrthancFramework/Sources/Toolbox.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/Sources/Toolbox.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -1884,7 +1884,7 @@
 #if defined(__unix__) && ORTHANC_SANDBOXED != 1
     static const char* LOCALTIME = "/etc/localtime";
     
-    if (!SystemToolbox::IsExistingFile(LOCALTIME))
+    if (!boost::filesystem::exists(LOCALTIME))
     {
       // Check out file
       // "boost_1_69_0/libs/locale/src/icu/time_zone.cpp": Direct
--- a/OrthancFramework/UnitTestsSources/DicomMapTests.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/UnitTestsSources/DicomMapTests.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -1466,7 +1466,7 @@
           
           {
             std::string dicom;
-            SystemToolbox::ReadFile(dicom, path);
+            SystemToolbox::ReadFile(dicom, current->path());
             
             ParsedDicomFile f(dicom);
             f.ExtractDicomSummary(m2, 256);
--- a/OrthancFramework/UnitTestsSources/FrameworkTests.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/UnitTestsSources/FrameworkTests.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -689,7 +689,7 @@
   {
     TemporaryFile tmp;
     std::string s = "Hello";
-    SystemToolbox::WriteFile(s, tmp.GetPath(), true /* call fsync() */);
+    SystemToolbox::WriteFile(s.c_str(), s.size(), tmp.GetPath(), true /* call fsync() */);
     std::string t;
     SystemToolbox::ReadFile(t, tmp.GetPath());
     ASSERT_EQ(s, t);
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -3558,12 +3558,12 @@
     std::string path = (std::string(getenv("HOME")) +
                         "/Subversion/orthanc-tests/Database/TransferSyntaxes/" +
                         std::string(GetTransferSyntaxUid(a)) + ".dcm");
-    if (Orthanc::SystemToolbox::IsRegularFile(path))
+    if (Orthanc::SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(path)))
     {
       printf("\n======= %s\n", GetTransferSyntaxUid(a));
 
       std::string source;
-      Orthanc::SystemToolbox::ReadFile(source, path);
+      Orthanc::SystemToolbox::ReadFile(source, Orthanc::SystemToolbox::PathFromUtf8(path));
 
       ParsedDicomFile dicom(source);
       std::unique_ptr<DcmElement> removal(dicom.GetDcmtkObject().getDataset()->remove(DCM_PixelData));
@@ -3623,12 +3623,12 @@
       std::string path = (std::string(getenv("HOME")) +
                           "/Subversion/orthanc-tests/Database/TransferSyntaxes/" +
                           std::string(GetTransferSyntaxUid(a)) + ".dcm");
-      if (Orthanc::SystemToolbox::IsRegularFile(path))
+      if (Orthanc::SystemToolbox::IsRegularFile(SystemToolbox::PathFromUtf8(path)))
       {
         printf("\n======= %s\n", GetTransferSyntaxUid(a));
 
         std::string source;
-        Orthanc::SystemToolbox::ReadFile(source, path);
+        Orthanc::SystemToolbox::ReadFile(source, SystemToolbox::PathFromUtf8(path));
 
         std::string c, k;
         try
--- a/OrthancFramework/UnitTestsSources/ImageTests.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancFramework/UnitTestsSources/ImageTests.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -77,7 +77,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/ColorPattern.png", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.png");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/ColorPattern.png"));
 #endif
 
   std::string md5;
@@ -137,7 +137,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Color16Pattern.png", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Color16Pattern.png");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/Color16Pattern.png"));
 #endif
 
   std::string md5;
@@ -172,7 +172,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray8Pattern.png", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.png");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/Gray8Pattern.png"));
 #endif
 
   std::string md5;
@@ -208,7 +208,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray16Pattern.png", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.png");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/Gray16Pattern.png"));
 #endif
 
   std::string md5;
@@ -313,7 +313,7 @@
     Orthanc::SystemToolbox::WriteFile(s, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/hello2.jpg"));
 
     std::string t;
-    Orthanc::SystemToolbox::ReadFile(t, "UnitTestsResults/hello.jpg");
+    Orthanc::SystemToolbox::ReadFile(t, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/hello.jpg"));
     ASSERT_EQ(s.size(), t.size());
     ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size()));
 #endif
@@ -385,7 +385,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/ColorPattern.pam", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/ColorPattern.pam");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/ColorPattern.pam"));
 #endif
 
   std::string md5;
@@ -419,7 +419,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray8Pattern.pam", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray8Pattern.pam");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/Gray8Pattern.pam"));
 #endif
   
   std::string md5;
@@ -455,7 +455,7 @@
   Orthanc::IImageWriter::WriteToMemory(w, f, accessor);
 #else
   Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/Gray16Pattern.pam", accessor);
-  Orthanc::SystemToolbox::ReadFile(f, "UnitTestsResults/Gray16Pattern.pam");
+  Orthanc::SystemToolbox::ReadFile(f, Orthanc::SystemToolbox::PathFromUtf8("UnitTestsResults/Gray16Pattern.pam"));
 #endif
 
   std::string md5;
--- a/OrthancServer/CMakeLists.txt	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/CMakeLists.txt	Wed Oct 29 22:20:23 2025 +0100
@@ -592,6 +592,7 @@
 
   add_library(ServeFolders SHARED 
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/ServeFolders/Plugin.cpp
+    ${CMAKE_SOURCE_DIR}/Plugins/Samples/ServeFolders/OrthancFrameworkDependencies.cpp
     ${SERVE_FOLDERS_RESOURCES}
     )
 
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -3951,17 +3951,17 @@
       std::string certificate(parameters.certificateFile);
       std::string key, password;
 
-      if (parameters.certificateKeyFile)
+      if (parameters.certificateKeyFile != NULL)
       {
         key.assign(parameters.certificateKeyFile);
       }
 
-      if (parameters.certificateKeyPassword)
+      if (parameters.certificateKeyPassword != NULL)
       {
         password.assign(parameters.certificateKeyPassword);
       }
 
-      client.SetClientCertificate(certificate, key, password);
+      client.SetClientCertificate(SystemToolbox::PathFromUtf8(certificate), SystemToolbox::PathFromUtf8(key), password);
     }
 
     client.SetPkcs11Enabled(parameters.pkcs11 ? true : false);
@@ -4980,14 +4980,14 @@
     {
       case _OrthancPluginService_GetOrthancPath:
       {
-        std::string s = SystemToolbox::GetPathToExecutable();
+        std::string s = SystemToolbox::PathToUtf8(SystemToolbox::GetPathToExecutable());
         *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
         return true;
       }
 
       case _OrthancPluginService_GetOrthancDirectory:
       {
-        std::string s = SystemToolbox::GetDirectoryOfExecutable();
+        std::string s = SystemToolbox::PathToUtf8(SystemToolbox::GetDirectoryOfExecutable());
         *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s);
         return true;
       }
--- a/OrthancServer/Plugins/Samples/AdoptDicomInstance/Plugin.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/AdoptDicomInstance/Plugin.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -79,9 +79,9 @@
     buffer.Assign(info.toStyledString());
     *customData = buffer.Release();
 
-    const std::string path = GetStorageDirectoryPath(uuid);
+    const boost::filesystem::path path = GetStorageDirectoryPath(uuid);
     LOG(WARNING) << "Creating non-adopted file: " << path;
-    Orthanc::SystemToolbox::WriteFile(content, size, path);
+    Orthanc::SystemToolbox::WriteFile(content, size, path, false /* no fsync */);
 
     return OrthancPluginErrorCode_Success;
   }
@@ -104,7 +104,7 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
     }
 
-    std::string path;
+    boost::filesystem::path path;
 
     if (info["IsAdopted"].asBool())
     {
@@ -153,7 +153,7 @@
     }
     else
     {
-      const std::string path = GetStorageDirectoryPath(uuid);
+      const boost::filesystem::path path = GetStorageDirectoryPath(uuid);
       LOG(WARNING) << "Removing non-adopted file from: " << path;
       Orthanc::SystemToolbox::RemoveFile(path);
     }
--- a/OrthancServer/Plugins/Samples/ConnectivityChecks/Plugin.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/ConnectivityChecks/Plugin.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -44,8 +44,9 @@
     return OrthancPluginErrorCode_Success;
   }
 
-  std::string path = "/" + std::string(request->groups[0]);
-  std::string mime = Orthanc::EnumerationToString(Orthanc::SystemToolbox::AutodetectMimeType(path));
+  const std::string path = "/" + std::string(request->groups[0]);
+  std::string mime = Orthanc::EnumerationToString(
+    Orthanc::SystemToolbox::AutodetectMimeType(Orthanc::SystemToolbox::PathFromUtf8(path)));
 
   try
   {
--- a/OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/DelayedDeletion/Plugin.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -26,6 +26,7 @@
 #include "../../../../OrthancFramework/Sources/FileStorage/FilesystemStorage.h"
 #include "../../../../OrthancFramework/Sources/Logging.h"
 #include "../../../../OrthancFramework/Sources/MultiThreading/SharedMessageQueue.h"
+#include "../../../../OrthancFramework/Sources/SystemToolbox.h"
 #include "../Common/OrthancPluginCppWrapper.h"
 
 #include <boost/thread.hpp>
@@ -329,9 +330,9 @@
       std::string pathStorage = orthancConfig.GetStringValue("StorageDirectory", "OrthancStorage");
       LOG(WARNING) << "DelayedDeletion - Path to the storage area: " << pathStorage;
 
-      storage_.reset(new Orthanc::FilesystemStorage(pathStorage));
+      storage_.reset(new Orthanc::FilesystemStorage(Orthanc::SystemToolbox::PathFromUtf8(pathStorage)));
 
-      boost::filesystem::path defaultDbPath = boost::filesystem::path(pathStorage) / (std::string("pending-deletions.") + databaseServerIdentifier_ + ".db");
+      boost::filesystem::path defaultDbPath = Orthanc::SystemToolbox::PathFromUtf8(pathStorage) / (std::string("pending-deletions.") + databaseServerIdentifier_ + ".db");
       std::string dbPath = delayedDeletionConfig.GetStringValue("Path", defaultDbPath.string());
 
       LOG(WARNING) << "DelayedDeletion - Path to the SQLite database: " << dbPath;
--- a/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -336,9 +336,10 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource);
       }
       Orthanc::SystemToolbox::RemoveFile(path);
-    }; break;
+      break;
+    }
+
     case WorklistStorageType_OrthancDb:
-    {
       if (worklistsStore_.get() != NULL)
       {
         std::string notUsed;
@@ -348,7 +349,8 @@
         }
         worklistsStore_->DeleteKey(worklistId);
       }
-    }; break;
+      break;
+
     default:
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
   }
@@ -449,7 +451,9 @@
       }
 
       Orthanc::SystemToolbox::ReadFile(fileContent, path);
-    }; break;
+      break;
+    }
+
     case WorklistStorageType_OrthancDb:
     {
       std::string serializedWl;
@@ -464,7 +468,9 @@
         Worklist wl(id, jsonWl);
         fileContent = wl.dicomContent_;
       }
-    }; break;
+      break;
+    }
+
     default:
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
   }
@@ -616,9 +622,10 @@
       switch (worklistStorage_)
       {
         case WorklistStorageType_Folder:
-        {
-          Orthanc::SystemToolbox::WriteFile(dicomContent, worklistDirectory_ / Orthanc::SystemToolbox::PathFromUtf8(worklistId + ".wl"), true);
-        }; break;
+          Orthanc::SystemToolbox::WriteFile(dicomContent.empty() ? NULL : dicomContent.c_str(), dicomContent.size(),
+                                            worklistDirectory_ / Orthanc::SystemToolbox::PathFromUtf8(worklistId + ".wl"), true);
+          break;
+
         case WorklistStorageType_OrthancDb:
         {
           Worklist wl(worklistId, dicomContent);
@@ -626,7 +633,9 @@
           wl.Serialize(serializedWl);
 
           worklistsStore_->Store(worklistId, serializedWl);
-        }; break;
+          break;
+        }
+
         default:
           throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
       }
@@ -643,43 +652,38 @@
   }
 
   static OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, 
-                                                OrthancPluginResourceType resourceType, 
-                                                const char *resourceId)
+                                                 OrthancPluginResourceType resourceType,
+                                                 const char *resourceId)
   {
     try
     {
-      switch (changeType)
+      if (changeType == OrthancPluginChangeType_OrthancStarted)
       {
-        case OrthancPluginChangeType_OrthancStarted:
+        Json::Value system;
+        bool hasKeyValueStores = (OrthancPlugins::RestApiGet(system, "/system", false) && system.isMember("Capabilities") &&
+                                  system["Capabilities"].isMember("HasKeyValueStores") && system["Capabilities"]["HasKeyValueStores"].asBool());
+
+        if (worklistStorage_ == WorklistStorageType_OrthancDb && !hasKeyValueStores)
         {
-          Json::Value system;
-          bool hasKeyValueStores = OrthancPlugins::RestApiGet(system, "/system", false) && system.isMember("Capabilities") && 
-                                   system["Capabilities"].isMember("HasKeyValueStores") && system["Capabilities"]["HasKeyValueStores"].asBool();
-
-          if (worklistStorage_ == WorklistStorageType_OrthancDb && !hasKeyValueStores)
-          {
-            LOG(ERROR) << "The Orthanc DB plugin does not support Key Value Stores.  It is therefore impossible to store the worklists in Orthanc Database";
-            return OrthancPluginErrorCode_IncompatibleConfigurations;
-          }                                 
+          LOG(ERROR) << "The Orthanc DB plugin does not support Key Value Stores.  It is therefore impossible to store the worklists in Orthanc Database";
+          return OrthancPluginErrorCode_IncompatibleConfigurations;
+        }
 
-          if (deleteDelayInHours_ > 0 && !hasKeyValueStores)
-          {
-            LOG(ERROR) << "The Orthanc DB plugin does not support Key Value Stores.  It is therefore impossible to use the \"DeleteWorklistsDelay\" option";
-            return OrthancPluginErrorCode_IncompatibleConfigurations;
-          }
+        if (deleteDelayInHours_ > 0 && !hasKeyValueStores)
+        {
+          LOG(ERROR) << "The Orthanc DB plugin does not support Key Value Stores.  It is therefore impossible to use the \"DeleteWorklistsDelay\" option";
+          return OrthancPluginErrorCode_IncompatibleConfigurations;
+        }
 
-          if (worklistStorage_ == WorklistStorageType_OrthancDb)
-          {
-            worklistsStore_.reset(new OrthancPlugins::KeyValueStore("worklists"));
-          }
+        if (worklistStorage_ == WorklistStorageType_OrthancDb)
+        {
+          worklistsStore_.reset(new OrthancPlugins::KeyValueStore("worklists"));
+        }
 
-          if (deleteDelayInHours_ > 0 || deleteWorklistsOnStableStudy_)
-          {
-            worklistHousekeeperThread_.reset(new boost::thread(WorklistHkWorkerThread));
-          }
-        }; break;
-        default:
-          break;
+        if (deleteDelayInHours_ > 0 || deleteWorklistsOnStableStudy_)
+        {
+          worklistHousekeeperThread_.reset(new boost::thread(WorklistHkWorkerThread));
+        }
       }
     }
     catch (Orthanc::OrthancException& e)
@@ -751,7 +755,7 @@
         }
         
         worklistStorage_ = WorklistStorageType_Folder;
-        worklistDirectory_ = Orthanc::SystemToolbox::PathFromUtf8(folder);
+        worklistDirectory_ = folder; //Orthanc::SystemToolbox::PathFromUtf8(folder);
         LOG(WARNING) << "The database of worklists will be read from folder: " << folder;
       }
       else if (worklists.GetBooleanValue("SaveInOrthancDatabase", false))
--- a/OrthancServer/Plugins/Samples/ServeFolders/CMakeLists.txt	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/ServeFolders/CMakeLists.txt	Wed Oct 29 22:20:23 2025 +0100
@@ -27,18 +27,24 @@
 SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
 SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
 
-SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
-SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of boost")
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../../OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../../../OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake)
 
-include(${CMAKE_SOURCE_DIR}/../Common/OrthancPlugins.cmake)
-include(${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Resources/CMake/JsonCppConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Resources/CMake/BoostConfiguration.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/../Common/OrthancPluginsExports.cmake)
+
+include_directories(
+  ${CMAKE_SOURCE_DIR}/../../Include/
+  )
 
 add_library(ServeFolders SHARED 
   Plugin.cpp
+  ${ORTHANC_CORE_SOURCES_DEPENDENCIES}
+  ${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Sources/Enumerations.cpp
+  ${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Sources/Logging.cpp
+  ${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Sources/OrthancException.cpp
+  ${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Sources/SystemToolbox.cpp
+  ${CMAKE_SOURCE_DIR}/../../../../OrthancFramework/Sources/Toolbox.cpp
   ${CMAKE_SOURCE_DIR}/../Common/OrthancPluginCppWrapper.cpp
-  ${JSONCPP_SOURCES}
-  ${BOOST_SOURCES}
   )
 
 DefineSourceBasenameForTarget(ServeFolders)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Plugins/Samples/ServeFolders/OrthancFrameworkDependencies.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -0,0 +1,54 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2023 Osimis S.A., Belgium
+ * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium
+ * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+/**
+ * Remove the dependency upon ICU in plugins, as this greatly increase
+ * the size of the resulting binaries, since they must embed the ICU
+ * dictionary.
+ **/
+
+#if BOOST_LOCALE_WITH_ICU == 1
+#  undef BOOST_LOCALE_WITH_ICU
+#  if ORTHANC_STATIC_ICU == 1
+#    include <unicode/udata.h>
+
+// Define an empty ICU dictionary for static builds
+extern "C"
+{
+  struct
+  {
+    double bogus;
+    uint8_t *bytes;
+  } U_ICUDATA_ENTRY_POINT = { 0.0, NULL };
+}
+
+#  endif
+#endif
+
+
+#include "../../../../OrthancFramework/Sources/ChunkedBuffer.cpp"
+#include "../../../../OrthancFramework/Sources/Enumerations.cpp"
+#include "../../../../OrthancFramework/Sources/Logging.cpp"
+#include "../../../../OrthancFramework/Sources/OrthancException.cpp"
+#include "../../../../OrthancFramework/Sources/SystemToolbox.cpp"
+#include "../../../../OrthancFramework/Sources/Toolbox.cpp"
--- a/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -25,6 +25,8 @@
 
 #include "../Common/OrthancPluginCppWrapper.h"
 
+#include "../../../../OrthancFramework/Sources/SystemToolbox.h"
+
 #include <json/value.h>
 #include <boost/filesystem.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -158,11 +160,11 @@
   if (LookupFolder(folder, output, request))
   {
     const fs::path item(request->groups[1]);
-    const fs::path parent((fs::path(folder) / item).parent_path());
+    const fs::path parent((Orthanc::SystemToolbox::PathFromUtf8(folder) / item).parent_path());
 
     if (item.filename().string() == "index.html" &&
         fs::is_directory(parent) &&
-        !fs::is_regular_file(fs::path(folder) / item))
+        !fs::is_regular_file(Orthanc::SystemToolbox::PathFromUtf8(folder) / item))
     {
       // On-the-fly generation of an "index.html" 
       std::string s;
@@ -216,7 +218,7 @@
       }
 
       boost::posix_time::ptime lastModification =
-        boost::posix_time::from_time_t(fs::last_write_time(path));
+        boost::posix_time::from_time_t(fs::last_write_time(Orthanc::SystemToolbox::PathFromUtf8(path)));
       std::string t = boost::posix_time::to_iso_string(lastModification);
       OrthancPluginSetHttpHeader(OrthancPlugins::GetGlobalContext(),
                                  output, "Last-Modified", t.c_str());
--- a/OrthancServer/Resources/Samples/Tools/RecoverCompressedFile.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Resources/Samples/Tools/RecoverCompressedFile.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -63,7 +63,7 @@
   if (arguments.size() != 2 && arguments.size() != 3)
   {
     fprintf(stderr, "Maintenance tool to recover a DICOM file that was compressed by Orthanc.\n\n");
-    fprintf(stderr, "Usage: %s <input> [output]\n", Orthanc::SystemToolbox::PathToUtf8(arguments[0]).c_str());
+    fprintf(stderr, "Usage: %s <input> [output]\n", arguments[0].c_str());
     fprintf(stderr, "If \"output\" is not given, the data will be output to stdout\n");
     return -1;
   }
--- a/OrthancServer/Sources/EmbeddedResourceHttpHandler.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Sources/EmbeddedResourceHttpHandler.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -67,7 +67,7 @@
     }
 
     std::string resourcePath = Toolbox::FlattenUri(uri, baseUri_.size());
-    MimeType contentType = SystemToolbox::AutodetectMimeType(resourcePath);
+    MimeType contentType = SystemToolbox::AutodetectMimeType(Orthanc::SystemToolbox::PathFromUtf8(resourcePath));
 
     try
     {
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -494,7 +494,7 @@
 
     std::string target;
     call.BodyToString(target);
-    SystemToolbox::WriteFile(dicom, target);
+    SystemToolbox::WriteFile(dicom, SystemToolbox::PathFromUtf8(target));
 
     call.GetOutput().AnswerBuffer("{}", MimeType_Json);
   }
--- a/OrthancServer/Sources/main.cpp	Wed Oct 29 14:37:47 2025 +0100
+++ b/OrthancServer/Sources/main.cpp	Wed Oct 29 22:20:23 2025 +0100
@@ -2042,7 +2042,7 @@
         }
         else
         {
-          SystemToolbox::WriteFile(configurationSample, target);
+          SystemToolbox::WriteFile(configurationSample, SystemToolbox::PathFromUtf8(target));
         }
         return 0;
       }
@@ -2093,7 +2093,7 @@
         }
         else
         {
-          SystemToolbox::WriteFile(s, target);
+          SystemToolbox::WriteFile(s, SystemToolbox::PathFromUtf8(target));
         }
         return 0;
       }
@@ -2127,7 +2127,7 @@
         }
         else
         {
-          SystemToolbox::WriteFile(cheatsheet, target);
+          SystemToolbox::WriteFile(cheatsheet, SystemToolbox::PathFromUtf8(target));
         }
         return 0;
       }