|
|
|
@ -434,16 +434,8 @@ void IterateDirEntries(const std::filesystem::path& path, const DirEntryCallable |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (True(filter & DirEntryFilter::File) && |
|
|
|
entry.status().type() == fs::file_type::regular) { |
|
|
|
if (!callback(entry)) { |
|
|
|
callback_error = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (True(filter & DirEntryFilter::Directory) && |
|
|
|
entry.status().type() == fs::file_type::directory) { |
|
|
|
if ((True(filter & DirEntryFilter::File) && entry.status().type() == fs::file_type::regular) |
|
|
|
|| (True(filter & DirEntryFilter::Directory) && entry.status().type() == fs::file_type::directory)) { |
|
|
|
if (!callback(entry)) { |
|
|
|
callback_error = true; |
|
|
|
break; |
|
|
|
@ -485,44 +477,24 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path, |
|
|
|
|
|
|
|
std::error_code ec; |
|
|
|
|
|
|
|
// TODO (Morph): Replace this with recursive_directory_iterator once it's fixed in MSVC.
|
|
|
|
for (const auto& entry : fs::directory_iterator(path, ec)) { |
|
|
|
// MSVC should now be fixed... right... right?!?!?!
|
|
|
|
for (const auto& entry : fs::recursive_directory_iterator(path, ec)) { |
|
|
|
if (ec) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (True(filter & DirEntryFilter::File) && |
|
|
|
entry.status().type() == fs::file_type::regular) { |
|
|
|
if ((True(filter & DirEntryFilter::File) && entry.status().type() == fs::file_type::regular) |
|
|
|
|| (True(filter & DirEntryFilter::Directory) && entry.status().type() == fs::file_type::directory)) { |
|
|
|
if (!callback(entry)) { |
|
|
|
callback_error = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (True(filter & DirEntryFilter::Directory) && |
|
|
|
entry.status().type() == fs::file_type::directory) { |
|
|
|
if (!callback(entry)) { |
|
|
|
callback_error = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO (Morph): Remove this when MSVC fixes recursive_directory_iterator.
|
|
|
|
// recursive_directory_iterator throws an exception despite passing in a std::error_code.
|
|
|
|
if (entry.status().type() == fs::file_type::directory) { |
|
|
|
IterateDirEntriesRecursively(entry.path(), callback, filter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (callback_error || ec) { |
|
|
|
LOG_ERROR(Common_Filesystem, |
|
|
|
"Failed to visit all the directory entries of path={}, ec_message={}", |
|
|
|
PathToUTF8String(path), ec.message()); |
|
|
|
LOG_ERROR(Common_Filesystem, "Failed to visit all the directory entries of path={}, ec_message={}", PathToUTF8String(path), ec.message()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
LOG_DEBUG(Common_Filesystem, "Successfully visited all the directory entries of path={}", |
|
|
|
PathToUTF8String(path)); |
|
|
|
LOG_DEBUG(Common_Filesystem, "Successfully visited all the directory entries of path={}", PathToUTF8String(path)); |
|
|
|
} |
|
|
|
|
|
|
|
// Generic Filesystem Operations
|
|
|
|
|