1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-15 14:54:09 +02:00

make BufferedFileStream act like UnbufferedFileStream

This commit is contained in:
EinBurgbauer 2021-12-09 20:04:17 +01:00
parent 32966b79a6
commit e13f194c6f

View file

@ -296,6 +296,15 @@ namespace System.IO
}
}
public override int64 Position
{
set
{
// Matches the behavior of Platform.BfpFile_Seek(mBfpFile, value, .Absolute);
mPos = Math.Max(value, 0);
}
}
public this()
{
@ -416,6 +425,27 @@ namespace System.IO
mFileAccess = access;
}
public override Result<void> Seek(int64 pos, SeekKind seekKind = .Absolute)
{
int64 newPos;
switch (seekKind)
{
case .Absolute:
newPos = pos;
case .FromEnd:
newPos = Length + pos;
case .Relative:
newPos = mPos + pos;
}
// Matches the behaviour of Platform.BfpFile_Seek(mBfpFile, value, .Absolute);
mPos = Math.Max(newPos, 0);
if (seekKind == .Absolute && newPos < 0)
return .Err;
return .Ok;
}
public override Result<void> Close()
{
let ret = base.Close();