mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Fix bugs when copying directories
- CopyDirectoryRecursively would try to create directories on the source FS instead of the destination FS. - Don't output file name twice in CopyDirectoryRecursively .
This commit is contained in:
parent
a76b0ef075
commit
6910049070
1 changed files with 5 additions and 4 deletions
|
@ -51,7 +51,10 @@ public static class FileSystemExtensions
|
||||||
Result rc = closure.DestinationPathBuffer.AppendChild(entry.Name);
|
Result rc = closure.DestinationPathBuffer.AppendChild(entry.Name);
|
||||||
if (rc.IsFailure()) return rc;
|
if (rc.IsFailure()) return rc;
|
||||||
|
|
||||||
return closure.SourceFileSystem.CreateDirectory(in closure.DestinationPathBuffer);
|
rc = closure.DestFileSystem.CreateDirectory(in closure.DestinationPathBuffer);
|
||||||
|
if (rc.IsFailure() && !ResultFs.PathAlreadyExists.Includes(rc)) return rc.Miss();
|
||||||
|
|
||||||
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result OnExitDir(in Path path, in DirectoryEntry entry, ref Utility.FsIterationTaskClosure closure)
|
static Result OnExitDir(in Path path, in DirectoryEntry entry, ref Utility.FsIterationTaskClosure closure)
|
||||||
|
@ -92,8 +95,6 @@ public static class FileSystemExtensions
|
||||||
in Path sourcePath, Span<byte> workBuffer, IProgressReport logger = null,
|
in Path sourcePath, Span<byte> workBuffer, IProgressReport logger = null,
|
||||||
CreateFileOptions option = CreateFileOptions.None)
|
CreateFileOptions option = CreateFileOptions.None)
|
||||||
{
|
{
|
||||||
logger?.LogMessage(sourcePath.ToString());
|
|
||||||
|
|
||||||
// Open source file.
|
// Open source file.
|
||||||
using var sourceFile = new UniqueRef<IFile>();
|
using var sourceFile = new UniqueRef<IFile>();
|
||||||
Result rc = sourceFileSystem.OpenFile(ref sourceFile.Ref(), sourcePath, OpenMode.Read);
|
Result rc = sourceFileSystem.OpenFile(ref sourceFile.Ref(), sourcePath, OpenMode.Read);
|
||||||
|
@ -136,7 +137,7 @@ public static class FileSystemExtensions
|
||||||
{
|
{
|
||||||
var destFs = new LocalFileSystem(destinationPath);
|
var destFs = new LocalFileSystem(destinationPath);
|
||||||
|
|
||||||
source.CopyDirectory(destFs, "/", "/", logger);
|
source.CopyDirectory(destFs, "/", "/", logger).ThrowIfFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<DirectoryEntryEx> EnumerateEntries(this IFileSystem fileSystem)
|
public static IEnumerable<DirectoryEntryEx> EnumerateEntries(this IFileSystem fileSystem)
|
||||||
|
|
Loading…
Reference in a new issue