Ensure EnsureDirectoryExists works properly

This commit is contained in:
Alex Barney 2019-08-08 17:28:34 -05:00
parent b03973dc48
commit ea2572c479
3 changed files with 11 additions and 5 deletions

View file

@ -233,7 +233,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] == '/')
{
@ -242,6 +244,8 @@ namespace LibHac.Fs
fs.CreateDirectory(subPath);
}
}
fs.CreateDirectory(path);
}
public static void CreateOrOverwriteFile(this IFileSystem fs, string path, long size)

View file

@ -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] == '/')
{

View file

@ -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)