[+] AuFS::CopyDirectory
This commit is contained in:
parent
44afa1e3de
commit
c52c1c89f1
@ -54,6 +54,17 @@ namespace Aurora::IO::FS
|
|||||||
*/
|
*/
|
||||||
AUKN_SYM bool DirDeleterEx(const AuString &string, AuList<AuString> &failingPaths);
|
AUKN_SYM bool DirDeleterEx(const AuString &string, AuList<AuString> &failingPaths);
|
||||||
|
|
||||||
|
struct CopyDirResult
|
||||||
|
{
|
||||||
|
AuList<AuString> errorCopyPaths;
|
||||||
|
AuList<AuString> errorTraversePaths;
|
||||||
|
AuList<AuString> copyPathsSuccess;
|
||||||
|
};
|
||||||
|
|
||||||
|
AUKN_SYM void CopyDirectory(const AuList<AuPair<AuString, AuString>> &pendingWork,
|
||||||
|
bool bUseResult,
|
||||||
|
CopyDirResult *out);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes a blob into a file chunk-by-chunk.
|
* @brief Writes a blob into a file chunk-by-chunk.
|
||||||
* The directory structure may or may not exist for the write operation to succeed.
|
* The directory structure may or may not exist for the write operation to succeed.
|
||||||
|
@ -433,6 +433,63 @@ namespace Aurora::IO::FS
|
|||||||
return bOk;
|
return bOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AUKN_SYM void CopyDirectory(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::Copy(rawPath + AuString({ AuFS::kPathSplitter }) + file, rawPathDest + AuString({ AuFS::kPathSplitter }) + file))
|
||||||
|
{
|
||||||
|
if (!bUseResult)
|
||||||
|
{
|
||||||
|
SysPushErrorIO("failed to copy: {}", 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)
|
AUKN_SYM bool NormalizePath(AuString &out, const AuString &in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user