mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Make SaveFs writable
This commit is contained in:
parent
4a43c330b6
commit
0eaefba071
2 changed files with 22 additions and 6 deletions
|
@ -76,12 +76,29 @@ namespace LibHac.Save
|
|||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
int remaining = count;
|
||||
int outOffset = offset;
|
||||
|
||||
while (remaining > 0)
|
||||
{
|
||||
int remainingInSegment = Iterator.CurrentSegmentSize * BlockSize - SegmentPos;
|
||||
int bytesToWrite = Math.Min(remaining, remainingInSegment);
|
||||
Data.Write(buffer, outOffset, bytesToWrite);
|
||||
|
||||
outOffset += bytesToWrite;
|
||||
remaining -= bytesToWrite;
|
||||
|
||||
if (SegmentPos >= Iterator.CurrentSegmentSize * BlockSize)
|
||||
{
|
||||
if (!Iterator.MoveNext()) return;
|
||||
Data.Position = Iterator.PhysicalBlock * BlockSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => true;
|
||||
public override bool CanWrite => false;
|
||||
public override bool CanWrite => true;
|
||||
public override long Length { get; }
|
||||
|
||||
public override long Position
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace LibHac.Save
|
|||
public Header Header { get; }
|
||||
public SharedStreamSource SavefileSource { get; }
|
||||
|
||||
private JournalStream JournalStream { get; }
|
||||
public SharedStreamSource JournalStreamSource { get; }
|
||||
private HierarchicalIntegrityVerificationStream IvfcStream { get; }
|
||||
public SharedStreamSource IvfcStreamSource { get; }
|
||||
|
@ -47,8 +46,8 @@ namespace LibHac.Save
|
|||
|
||||
Stream journalData = DataRemapStorage.OpenStream(layout.JournalDataOffset,
|
||||
layout.JournalDataSizeB + layout.SizeReservedArea);
|
||||
JournalStream = new JournalStream(journalData, journalMap, (int)Header.Journal.BlockSize);
|
||||
JournalStreamSource = new SharedStreamSource(JournalStream);
|
||||
var journalStream = new JournalStream(journalData, journalMap, (int)Header.Journal.BlockSize);
|
||||
JournalStreamSource = new SharedStreamSource(journalStream);
|
||||
|
||||
IvfcStream = InitIvfcStream(integrityCheckLevel);
|
||||
|
||||
|
@ -106,7 +105,7 @@ namespace LibHac.Save
|
|||
IvfcLevelHeader level = ivfc.LevelHeaders[i - 1];
|
||||
|
||||
Stream data = i == ivfcLevels - 1
|
||||
? JournalStream
|
||||
? JournalStreamSource.CreateStream()
|
||||
: MetaRemapStorage.OpenStream(level.LogicalOffset, level.HashDataSize);
|
||||
|
||||
initInfo[i] = new IntegrityVerificationInfo
|
||||
|
|
Loading…
Reference in a new issue