mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Account for empty files
This commit is contained in:
parent
f074d89d46
commit
a6a9392047
2 changed files with 5 additions and 3 deletions
|
@ -9,11 +9,12 @@ namespace libhac.Savefile
|
|||
public int ParentDirIndex { get; }
|
||||
public string Name { get; }
|
||||
public int Field44 { get; }
|
||||
public int Offset { get; }
|
||||
public int BlockIndex { get; }
|
||||
public long Size { get; }
|
||||
public long Field54 { get; }
|
||||
public int NextIndex { get; }
|
||||
|
||||
public long Offset { get; internal set; }
|
||||
public string FullPath { get; private set; }
|
||||
public FileEntry ParentDir { get; internal set; }
|
||||
public FileEntry Next { get; internal set; }
|
||||
|
@ -26,7 +27,7 @@ namespace libhac.Savefile
|
|||
reader.BaseStream.Position = start + 0x44;
|
||||
|
||||
Field44 = reader.ReadInt32();
|
||||
Offset = reader.ReadInt32();
|
||||
BlockIndex = reader.ReadInt32();
|
||||
Size = reader.ReadInt64();
|
||||
Field54 = reader.ReadInt64();
|
||||
NextIndex = reader.ReadInt32();
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace libhac.Savefile
|
|||
|
||||
public Stream OpenFile(FileEntry file)
|
||||
{
|
||||
return new SubStream(JournalStream, file.Offset * Header.Save.BlockSize, file.Size);
|
||||
return new SubStream(JournalStream, file.Offset, file.Size);
|
||||
}
|
||||
|
||||
public bool FileExists(string filename) => FileDict.ContainsKey(filename);
|
||||
|
@ -142,6 +142,7 @@ namespace libhac.Savefile
|
|||
if (file.NextIndex != 0) file.Next = fileEntries[file.NextIndex];
|
||||
if (file.ParentDirIndex != 0 && file.ParentDirIndex < dirEntries.Length)
|
||||
file.ParentDir = dirEntries[file.ParentDirIndex];
|
||||
file.Offset = file.BlockIndex < 0 ? 0 : file.BlockIndex * blockSize;
|
||||
}
|
||||
|
||||
Files = new FileEntry[fileEntries.Length - 2];
|
||||
|
|
Loading…
Reference in a new issue