mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 03:18:55 +02:00
[fs] use recursive_directory_iterator since MSVC CRT no longer should bug out
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
8678cb06eb
commit
35ef37ad03
1 changed files with 8 additions and 36 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue