sal/Library_sal.mk  |    1 +
 sal/osl/all/log.cxx |    7 +++++++
 2 files changed, 8 insertions(+)

New commits:
commit 9fb2fa9bddef863c1e444861f939d4d7956dcc4b
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Fri Mar 22 17:10:51 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Mon Mar 25 15:45:37 2024 +0100

    Best effort to create directories of SAL_LOG_FILE
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165272
    Tested-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    (cherry picked from commit 1339c42c4aea269e5265277647361ae91882d8a5)
    Conflicts:
            sal/Library_sal.mk
            sal/osl/all/log.cxx
    
    Change-Id: Ia86ac0e022579d155e92de3b853d57860b5b97e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165192
    Tested-by: allotropia jenkins <jenk...@allotropia.de>
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk
index e84ed0aaf1b5..53b35dc8342b 100644
--- a/sal/Library_sal.mk
+++ b/sal/Library_sal.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_libs,sal,\
        $(if $(filter LINUX,$(OS)), \
                -ldl \
                -lrt \
+               -lstdc++fs \
        ) \
        $(if $(filter SOLARIS,$(OS)), \
                -lnsl \
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 84f88f259daa..3377d615a6ab 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -19,9 +19,13 @@
 
 #include <stdio.h>
 #include <string.h>
+#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
+#include <experimental/filesystem>
 #include <fstream>
+#include <system_error>
 
 #include <config_global.h>
+#include <o3tl/temporary.hxx>
 #include <osl/thread.hxx>
 #include <rtl/string.h>
 #include <sal/detail/log.h>
@@ -201,6 +205,9 @@ std::ofstream * getLogFile() {
 
         if (logFile)
         {
+            std::experimental::filesystem::create_directories(
+                std::experimental::filesystem::path(logFile).remove_filename(),
+                o3tl::temporary(std::error_code()));
             // stays until process exits
             static std::ofstream file(logFile, std::ios::app | std::ios::out);
             pResult = &file;

Reply via email to