aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-12-07 11:21:41 +0100
committerGitHub <[email protected]>2022-12-07 02:21:41 -0800
commit100c8f966b1c5b2fb190748f0177600562d1c5fe (patch)
treefc85e350dea47330149a1d42eb7a6c7ae0a06111 /zencore/filesystem.cpp
parentCache request record/replay (#198) (diff)
downloadzen-100c8f966b1c5b2fb190748f0177600562d1c5fe.tar.xz
zen-100c8f966b1c5b2fb190748f0177600562d1c5fe.zip
optimizations (#200)
* Use direct file read and direct buffer allocation for small IoBuffer materalization * Reduce range of materialized data in CompositeBuffer reading CompressedBuffer header reading often only need a small part and not the whole file * reduce lock contention in IoBuffer::Materialize * Reduce parsing of compressed headers Validate header type at decompression * faster CreateDirectories - start from leaf going up and recurse back * optimized BufferHeader::IsValid * Add ValidateCompressedHeader to use when we don't need the actual compressed data Validate that we always get compressed data in CidStore::AddChunk * changelog
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index 0aa478404..1e4a52638 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -188,13 +188,21 @@ CleanDirectory(const wchar_t* DirPath)
bool
CreateDirectories(const std::filesystem::path& Dir)
{
- std::error_code ErrorCode;
- bool WasCreated = std::filesystem::create_directories(Dir, ErrorCode);
- if (ErrorCode)
+ while (!std::filesystem::is_directory(Dir))
{
- throw std::system_error(ErrorCode, fmt::format("Failed to create directories for '{}'", Dir.string()));
+ if (Dir.has_parent_path())
+ {
+ CreateDirectories(Dir.parent_path());
+ }
+ std::error_code ErrorCode;
+ std::filesystem::create_directory(Dir, ErrorCode);
+ if (ErrorCode)
+ {
+ throw std::system_error(ErrorCode, fmt::format("Failed to create directories for '{}'", Dir.string()));
+ }
+ return true;
}
- return WasCreated;
+ return false;
}
bool