Misc code accuracy fixes

This commit is contained in:
Alex Barney 2022-02-24 16:26:23 -07:00
parent a2c64797a9
commit 4e23465982
3 changed files with 10 additions and 6 deletions

View file

@ -155,7 +155,7 @@ public static class PathFormatter
currentPath = path.Slice(1);
}
else if (path.Length != 0 && WindowsPath.IsWindowsDrive(path.Slice(1)))
else if (WindowsPath.IsWindowsDrive(path.Slice(1)))
{
if (normalizeBuffer.Length == 0)
return ResultFs.NotNormalized.Log();
@ -356,8 +356,12 @@ public static class PathFormatter
if (path.At(0) == Dot && (path.At(1) == NullTerminator || path.At(1) == DirectorySeparator ||
path.At(1) == AltDirectorySeparator))
{
if (relativePathBuffer.Length >= 2)
if (relativePathBuffer.Length != 0)
{
// Note: Nintendo doesn't check if the buffer is long enough here
if (relativePathBuffer.Length < 2)
return ResultFs.TooLongPath.Log();
relativePathBuffer[0] = Dot;
relativePathBuffer[1] = NullTerminator;
}

View file

@ -49,7 +49,7 @@ public class FileInterfaceAdapter : IFileSf
if (offset < 0)
return ResultFs.InvalidOffset.Log();
if (destination.Size < 0)
if (size < 0)
return ResultFs.InvalidSize.Log();
if (destination.Size < (int)size)
@ -78,7 +78,7 @@ public class FileInterfaceAdapter : IFileSf
if (offset < 0)
return ResultFs.InvalidOffset.Log();
if (source.Size < 0)
if (size < 0)
return ResultFs.InvalidSize.Log();
if (source.Size < (int)size)

View file

@ -33,7 +33,7 @@ public class StorageInterfaceAdapter : IStorageSf
if (offset < 0)
return ResultFs.InvalidOffset.Log();
if (destination.Size < 0)
if (size < 0)
return ResultFs.InvalidSize.Log();
if (destination.Size < size)
@ -58,7 +58,7 @@ public class StorageInterfaceAdapter : IStorageSf
if (offset < 0)
return ResultFs.InvalidOffset.Log();
if (source.Size < 0)
if (size < 0)
return ResultFs.InvalidSize.Log();
if (source.Size < size)