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:
parent
85273962be
commit
81b98575c6
1 changed files with 17 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue