From d92b509bda1f7a292d4ccb88cc227b179292a5e7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 28 Mar 2025 13:15:21 -0400 Subject: [PATCH] Fix windows build PR #12767 accidentally broke it. (cherry picked from commit 99041b4d84e48b746908b8f0a6cffb32cd1be4a9) --- src/libstore/local-store.cc | 2 +- src/libutil/file-system.cc | 4 ++-- src/libutil/file-system.hh | 8 +++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 4a5c5072d..b4a023928 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -213,7 +213,7 @@ LocalStore::LocalStore( state->stmts = std::make_unique(); /* Create missing state directories if they don't already exist. */ - createDirs(realStoreDir); + createDirs(realStoreDir.get()); if (readOnly) { experimentalFeatureSettings.require(Xp::ReadOnlyLocalStore); } else { diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index 558593ca3..09099ce53 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -419,12 +419,12 @@ void createDir(const Path & path, mode_t mode) throw SysError("creating directory '%1%'", path); } -void createDirs(const Path & path) +void createDirs(const fs::path & path) { try { fs::create_directories(path); } catch (fs::filesystem_error & e) { - throw SysError("creating directory '%1%'", path); + throw SysError("creating directory '%1%'", path.string()); } } diff --git a/src/libutil/file-system.hh b/src/libutil/file-system.hh index 7d2f6a916..ed1112c7e 100644 --- a/src/libutil/file-system.hh +++ b/src/libutil/file-system.hh @@ -171,12 +171,10 @@ void deletePath(const std::filesystem::path & path, uint64_t & bytesFreed); /** * Create a directory and all its parents, if necessary. + * + * Wrapper around `std::filesystem::create_directories` to handle exceptions. */ -void createDirs(const Path & path); -inline void createDirs(PathView path) -{ - return createDirs(Path(path)); -} +void createDirs(const std::filesystem::path & path); /** * Create a single directory.