aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-10 23:08:55 +0100
committerGitHub <[email protected]>2023-11-10 23:08:55 +0100
commitb0dceea396d8c7b7702e57b51d46b4a12a003902 (patch)
treeb344d3d3ab393554c0fe02c3510b260245e88792 /src/zencore/filesystem.cpp
parentfix bad access to unlocked state (#527) (diff)
downloadzen-b0dceea396d8c7b7702e57b51d46b4a12a003902.tar.xz
zen-b0dceea396d8c7b7702e57b51d46b4a12a003902.zip
If a directory is deleted while we try to traverse it, skip it and continue (#528)
Diffstat (limited to 'src/zencore/filesystem.cpp')
-rw-r--r--src/zencore/filesystem.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index e9f7ba72c..b64c9973e 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -982,6 +982,11 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr
if (FAILED(hRes))
{
+ if (hRes == ERROR_FILE_NOT_FOUND)
+ {
+ // Directory no longer exist, treat it as empty
+ return;
+ }
ThrowSystemException(hRes, fmt::format("Failed to open handle to '{}'", RootDir));
}
@@ -1057,6 +1062,12 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr
DIR* Dir = opendir(RootDir.c_str());
if (Dir == nullptr)
{
+ int Err = errno;
+ if (Err == ENOENT)
+ {
+ // Directory no longer exist, treat it as empty
+ return;
+ }
ThrowLastError(fmt::format("Failed to open directory for traversal: {}", RootDir.c_str()));
}