|
@@ -280,6 +280,11 @@ namespace System.IO
|
|
|
|
|
|
class BufferedFileStream : BufferedStream, IFileStream
|
|
|
{
|
|
|
+ public struct PositionRestorer : this(BufferedFileStream stream, int prevPosition), IDisposable
|
|
|
+ {
|
|
|
+ public void Dispose() => stream.Position = prevPosition;
|
|
|
+ }
|
|
|
+
|
|
|
protected Platform.BfpFile* mBfpFile;
|
|
|
protected int64 mBfpFilePos;
|
|
|
FileAccess mFileAccess;
|
|
@@ -329,11 +334,6 @@ namespace System.IO
|
|
|
Delete();
|
|
|
}
|
|
|
|
|
|
- protected virtual void Delete()
|
|
|
- {
|
|
|
- Close();
|
|
|
- }
|
|
|
-
|
|
|
public this(Platform.BfpFile* handle, FileAccess access, int32 bufferSize, bool isAsync)
|
|
|
{
|
|
|
mBfpFile = handle;
|
|
@@ -440,6 +440,18 @@ namespace System.IO
|
|
|
return .Ok;
|
|
|
}
|
|
|
|
|
|
+ public PositionRestorer PushPosition(int position)
|
|
|
+ {
|
|
|
+ PositionRestorer restorer = .(this, Position);
|
|
|
+ Position = position;
|
|
|
+ return restorer;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected virtual void Delete()
|
|
|
+ {
|
|
|
+ Close();
|
|
|
+ }
|
|
|
+
|
|
|
public override Result<void> Seek(int64 pos, SeekKind seekKind = .Absolute)
|
|
|
{
|
|
|
int64 newPos;
|