mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 06:14:10 +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)
|
public void Align(int alignSize)
|
||||||
{
|
{
|
||||||
int64 pos = Length;
|
int64 pos = Position;
|
||||||
int64 alignAdd = alignSize - (pos % alignSize);
|
int64 length = Length;
|
||||||
if (alignAdd == alignSize)
|
|
||||||
|
int64 wantPos = Math.Align(pos, alignSize);
|
||||||
|
if (pos == wantPos)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (wantPos < length)
|
||||||
|
{
|
||||||
|
Position = wantPos;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length > pos)
|
||||||
|
{
|
||||||
|
Position = length;
|
||||||
|
pos = length;
|
||||||
|
}
|
||||||
|
int64 alignAdd = wantPos - pos;
|
||||||
int64 emptyData = 0;
|
int64 emptyData = 0;
|
||||||
while (alignAdd > 0)
|
while (alignAdd > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue