[+] AuFS::MoveDirectory
This commit is contained in:
parent
c52c1c89f1
commit
4a0eeefe1b
@ -65,6 +65,10 @@ namespace Aurora::IO::FS
|
||||
bool bUseResult,
|
||||
CopyDirResult *out);
|
||||
|
||||
AUKN_SYM void MoveDirectory(const AuList<AuPair<AuString, AuString>> &pendingWork,
|
||||
bool bUseResult,
|
||||
CopyDirResult *out);
|
||||
|
||||
/**
|
||||
* @brief Writes a blob into a file chunk-by-chunk.
|
||||
* The directory structure may or may not exist for the write operation to succeed.
|
||||
|
@ -489,6 +489,63 @@ namespace Aurora::IO::FS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AUKN_SYM void MoveDirectory(const AuList<AuPair<AuString, AuString>> &pendingWork,
|
||||
bool bUseResult,
|
||||
CopyDirResult *out)
|
||||
{
|
||||
AU_DEBUG_MEMCRUNCH;
|
||||
SysCheckArgNotNull(out, );
|
||||
|
||||
AuList<AuPair<AuString, AuString>> copyWork = pendingWork;
|
||||
|
||||
while (copyWork.size())
|
||||
{
|
||||
auto now = AuExchange(copyWork, {});
|
||||
|
||||
for (const auto &[rawPath, rawPathDest] : now)
|
||||
{
|
||||
AuList<AuString> files;
|
||||
if (AuFS::FilesInDirectory(rawPath, files))
|
||||
{
|
||||
for (const auto &file : files)
|
||||
{
|
||||
if (!AuFS::Relink(rawPath + AuString({ AuFS::kPathSplitter }) + file, rawPathDest + AuString({ AuFS::kPathSplitter }) + file))
|
||||
{
|
||||
if (!bUseResult)
|
||||
{
|
||||
SysPushErrorIO("failed to move: {}", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
out->errorCopyPaths.push_back(rawPath + AuString({ AuFS::kPathSplitter }) + file);
|
||||
}
|
||||
}
|
||||
else if (bUseResult)
|
||||
{
|
||||
out->copyPathsSuccess.push_back(rawPathDest + AuString({ AuFS::kPathSplitter }) + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuList<AuString> dirs;
|
||||
if (AuFS::DirsInDirectory(rawPath, dirs))
|
||||
{
|
||||
for (const auto &dir : dirs)
|
||||
{
|
||||
copyWork.push_back(AuMakePair(rawPath + AuString({ AuFS::kPathSplitter }) + dir, rawPathDest + AuString({ AuFS::kPathSplitter }) + dir));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bUseResult)
|
||||
{
|
||||
out->errorTraversePaths.push_back(rawPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AUKN_SYM bool NormalizePath(AuString &out, const AuString &in)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user