1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Made 'Align' work for both reading as well as writing

This commit is contained in:
Brian Fiete 2023-12-24 07:04:04 -05:00
parent 85273962be
commit 81b98575c6

View file

@ -225,11 +225,25 @@ namespace System.IO
public void Align(int alignSize)
{
int64 pos = Length;
int64 alignAdd = alignSize - (pos % alignSize);
if (alignAdd == alignSize)
int64 pos = Position;
int64 length = Length;
int64 wantPos = Math.Align(pos, alignSize);
if (pos == wantPos)
return;
if (wantPos < length)
{
Position = wantPos;
return;
}
if (length > pos)
{
Position = length;
pos = length;
}
int64 alignAdd = wantPos - pos;
int64 emptyData = 0;
while (alignAdd > 0)
{