[*] AuFS::MoveDirectory -> Try remove dirs afterwards (should only succeed if empty. failure is ignored and reported to CopyDirResult)

This commit is contained in:
Reece Wilson 2023-11-29 14:04:57 +00:00
parent dcf94a8b23
commit 42beaeabf5

View File

@ -498,6 +498,7 @@ namespace Aurora::IO::FS
SysCheckArgNotNull(out, );
AuList<AuPair<AuString, AuString>> copyWork = pendingWork;
AuList<AuString> 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)