Catch errors when checking an AesXtsFile's size

This commit is contained in:
Alex Barney 2019-01-20 15:39:19 -06:00
parent 0ed67d87df
commit 39f952015f

View file

@ -44,15 +44,22 @@ namespace LibHac.IO
private long GetAesXtsFileSize(string path) private long GetAesXtsFileSize(string path)
{ {
using (IFile file = BaseFileSystem.OpenFile(path, OpenMode.Read)) try
{ {
var buffer = new byte[8]; using (IFile file = BaseFileSystem.OpenFile(path, OpenMode.Read))
{
var buffer = new byte[8];
file.Read(buffer, 0x20); file.Read(buffer, 0x20);
if (BitConverter.ToUInt32(buffer, 0) != 0x3058414E) return 0; if (BitConverter.ToUInt32(buffer, 0) != 0x3058414E) return 0;
file.Read(buffer, 0x48); file.Read(buffer, 0x48);
return BitConverter.ToInt32(buffer, 0); return BitConverter.ToInt32(buffer, 0);
}
}
catch (ArgumentOutOfRangeException)
{
return 0;
} }
} }
} }