diff --git a/src/LibHac/Fs/FileSystemExtensions.cs b/src/LibHac/Fs/FileSystemExtensions.cs index 6a26db14..cc88706b 100644 --- a/src/LibHac/Fs/FileSystemExtensions.cs +++ b/src/LibHac/Fs/FileSystemExtensions.cs @@ -227,13 +227,15 @@ namespace LibHac.Fs { break; } - } + } } - + // path[i] will be a '/', so skip that character i++; - for (; i < path.Length; i++) + // loop until `path.Length - 1` so CreateDirectory won't be called multiple + // times on path if the last character in the path is a '/' + for (; i < path.Length - 1; i++) { if (path[i] == '/') { @@ -242,6 +244,8 @@ namespace LibHac.Fs fs.CreateDirectory(subPath); } } + + fs.CreateDirectory(path); } public static void CreateOrOverwriteFile(this IFileSystem fs, string path, long size) diff --git a/src/LibHac/Fs/FileSystemManagerUtils.cs b/src/LibHac/Fs/FileSystemManagerUtils.cs index 6ca37b03..7e0498f7 100644 --- a/src/LibHac/Fs/FileSystemManagerUtils.cs +++ b/src/LibHac/Fs/FileSystemManagerUtils.cs @@ -145,7 +145,9 @@ namespace LibHac.Fs // path[i] will be a '/', so skip that character i++; - for (; i < path.Length; i++) + // loop until `path.Length - 1` so CreateDirectory won't be called multiple + // times on path if the last character in the path is a '/' + for (; i < path.Length - 1; i++) { if (path[i] == '/') { diff --git a/src/hactoolnet/ProcessSave.cs b/src/hactoolnet/ProcessSave.cs index d60cba36..349a6dc7 100644 --- a/src/hactoolnet/ProcessSave.cs +++ b/src/hactoolnet/ProcessSave.cs @@ -14,7 +14,7 @@ namespace hactoolnet { public static void Process(Context ctx) { - FileAccess accessNeeded = FileAccess.Read; + var accessNeeded = FileAccess.Read; if (ctx.Options.SignSave || ctx.Options.ReplaceFileDest != null && ctx.Options.ReplaceFileSource != null || ctx.Options.RepackSource != null || ctx.Options.TrimSave)