mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-03 06:45:59 +02:00
Moving corlib files out of "System" directory into root
This commit is contained in:
parent
4cd58262e4
commit
7dbfd15292
179 changed files with 3 additions and 0 deletions
78
BeefLibs/corlib/src/IO/Substream.bf
Normal file
78
BeefLibs/corlib/src/IO/Substream.bf
Normal file
|
@ -0,0 +1,78 @@
|
|||
using System.IO;
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
class Substream : Stream
|
||||
{
|
||||
public bool mOwnsStream;
|
||||
Stream mChildStream ~ { if (mOwnsStream) delete _; };
|
||||
int64 mOffset;
|
||||
int64 mLength;
|
||||
|
||||
public override int64 Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return mChildStream.Position + mOffset;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mChildStream.Position = value + mOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public override int64 Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return mChildStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return mChildStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public this(Stream childStream, int64 offset, int64 length, bool ownsStream = false)
|
||||
{
|
||||
mChildStream = childStream;
|
||||
mOffset = offset;
|
||||
mLength = length;
|
||||
mOwnsStream = ownsStream;
|
||||
}
|
||||
|
||||
public override Result<int> TryRead(Span<uint8> data)
|
||||
{
|
||||
return mChildStream.TryRead(data);
|
||||
}
|
||||
|
||||
public override Result<int> TryWrite(Span<uint8> data)
|
||||
{
|
||||
return mChildStream.TryWrite(data);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
mChildStream.Close();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
mChildStream.Flush();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue