From 6910049070e0021de2ec5122837f7e7ac4fcb9a8 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sun, 12 Dec 2021 02:09:41 -0700 Subject: [PATCH] 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 . --- src/LibHac/FsSystem/FileSystemExtensions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/LibHac/FsSystem/FileSystemExtensions.cs b/src/LibHac/FsSystem/FileSystemExtensions.cs index 87ff3289..f254bca1 100644 --- a/src/LibHac/FsSystem/FileSystemExtensions.cs +++ b/src/LibHac/FsSystem/FileSystemExtensions.cs @@ -51,7 +51,10 @@ public static class FileSystemExtensions Result rc = closure.DestinationPathBuffer.AppendChild(entry.Name); 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) @@ -92,8 +95,6 @@ public static class FileSystemExtensions in Path sourcePath, Span workBuffer, IProgressReport logger = null, CreateFileOptions option = CreateFileOptions.None) { - logger?.LogMessage(sourcePath.ToString()); - // Open source file. using var sourceFile = new UniqueRef(); Result rc = sourceFileSystem.OpenFile(ref sourceFile.Ref(), sourcePath, OpenMode.Read); @@ -136,7 +137,7 @@ public static class FileSystemExtensions { var destFs = new LocalFileSystem(destinationPath); - source.CopyDirectory(destFs, "/", "/", logger); + source.CopyDirectory(destFs, "/", "/", logger).ThrowIfFailure(); } public static IEnumerable EnumerateEntries(this IFileSystem fileSystem)