diff --git a/Source/IO/FS/FS.cpp b/Source/IO/FS/FS.cpp index ca1bb64d..1cf82b20 100644 --- a/Source/IO/FS/FS.cpp +++ b/Source/IO/FS/FS.cpp @@ -498,6 +498,7 @@ namespace Aurora::IO::FS SysCheckArgNotNull(out, ); AuList> copyWork = pendingWork; + AuList dirsAll; while (copyWork.size()) { @@ -533,7 +534,9 @@ namespace Aurora::IO::FS { for (const auto &dir : dirs) { - copyWork.push_back(AuMakePair(rawPath + AuString({ AuFS::kPathSplitter }) + dir, rawPathDest + AuString({ AuFS::kPathSplitter }) + dir)); + auto fullDirPath = rawPath + AuString({ AuFS::kPathSplitter }) + dir; + copyWork.push_back(AuMakePair(fullDirPath, rawPathDest + AuString({ AuFS::kPathSplitter }) + dir)); + dirsAll.push_back(fullDirPath); } } else @@ -545,6 +548,37 @@ namespace Aurora::IO::FS } } } + + bool bSuccess {}; + do + { + bSuccess = false; + + for (auto itr = dirsAll.begin(); + itr != dirsAll.end(); + ) + { + if (AuFS::Remove(*itr)) + { + bSuccess |= true; + itr = dirsAll.end(); + } + else + { + itr++; + } + } + } + while (bSuccess && + dirsAll.size()); + + for (const auto &dir : dirsAll) + { + if (AuFS::DirExists(dir)) + { + out->errorTraversePaths.push_back(dir); + } + } } AUKN_SYM bool NormalizePath(AuString &out, const AuString &in)