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.