Merge pull request #6448 from Morph1984/recursive-dir-iterator
common: fs: Use the normal directory iterator in *Recursively functions
This commit is contained in:
		@@ -321,7 +321,8 @@ bool RemoveDirContentsRecursively(const fs::path& path) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    std::error_code ec;
 | 
					    std::error_code ec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const auto& entry : fs::recursive_directory_iterator(path, ec)) {
 | 
					    // TODO (Morph): Replace this with recursive_directory_iterator once it's fixed in MSVC.
 | 
				
			||||||
 | 
					    for (const auto& entry : fs::directory_iterator(path, ec)) {
 | 
				
			||||||
        if (ec) {
 | 
					        if (ec) {
 | 
				
			||||||
            LOG_ERROR(Common_Filesystem,
 | 
					            LOG_ERROR(Common_Filesystem,
 | 
				
			||||||
                      "Failed to completely enumerate the directory at path={}, ec_message={}",
 | 
					                      "Failed to completely enumerate the directory at path={}, ec_message={}",
 | 
				
			||||||
@@ -337,6 +338,12 @@ bool RemoveDirContentsRecursively(const fs::path& path) {
 | 
				
			|||||||
                      PathToUTF8String(entry.path()), ec.message());
 | 
					                      PathToUTF8String(entry.path()), ec.message());
 | 
				
			||||||
            break;
 | 
					            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) {
 | 
				
			||||||
 | 
					            return RemoveDirContentsRecursively(entry.path());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (ec) {
 | 
					    if (ec) {
 | 
				
			||||||
@@ -475,7 +482,8 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    std::error_code ec;
 | 
					    std::error_code ec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const auto& entry : fs::recursive_directory_iterator(path, ec)) {
 | 
					    // TODO (Morph): Replace this with recursive_directory_iterator once it's fixed in MSVC.
 | 
				
			||||||
 | 
					    for (const auto& entry : fs::directory_iterator(path, ec)) {
 | 
				
			||||||
        if (ec) {
 | 
					        if (ec) {
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -495,6 +503,12 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
 | 
				
			|||||||
                break;
 | 
					                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) {
 | 
					    if (callback_error || ec) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user