Death::IO::BoundedFileStream class

Provides only specified portion of the specified seekable input stream.

Base classes

class Stream
Provides a generic view of a sequence of bytes.

Constructors, destructors, conversion operators

BoundedFileStream(Containers::StringView path, std::uint64_t offset, std::uint32_t size, std::int32_t bufferSize = FileStream::DefaultBufferSize)
BoundedFileStream(Containers::String&& path, std::uint64_t offset, std::uint32_t size, std::int32_t bufferSize = FileStream::DefaultBufferSize)
BoundedFileStream(std::shared_ptr<FileStreamPool> pool, std::uint64_t offset, std::uint32_t size, std::int32_t bufferSize = FileStream::DefaultBufferSize)
Borrows the underlying stream from a pool instead of opening the file by path.
~BoundedFileStream() override
BoundedFileStream(const BoundedFileStream&) deleted

Public functions

auto operator=(const BoundedFileStream&) -> BoundedFileStream& deleted
void Dispose() override
Closes the stream and releases all assigned resources.
auto Seek(std::int64_t offset, SeekOrigin origin) -> std::int64_t override
Seeks in an opened stream.
auto GetPosition() const -> std::int64_t override
Tells the seek position of an opened stream.
auto Read(void* destination, std::int64_t bytesToRead) -> std::int64_t override
Reads a certain amount of bytes from the stream to a buffer.
auto Write(const void* source, std::int64_t bytesToWrite) -> std::int64_t override
Writes a certain amount of bytes from a buffer to the stream.
auto Flush() -> bool override
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
auto IsValid() -> bool override
Returns true if the stream has been sucessfully opened.
auto GetSize() const -> std::int64_t override
Returns stream size in bytes.
auto SetSize(std::int64_t size) -> std::int64_t override
Sets stream size in bytes.

Function documentation

Death::IO::BoundedFileStream::BoundedFileStream(std::shared_ptr<FileStreamPool> pool, std::uint64_t offset, std::uint32_t size, std::int32_t bufferSize = FileStream::DefaultBufferSize)

Borrows the underlying stream from a pool instead of opening the file by path.

The stream goes back to the pool in Dispose() (or the destructor), keeping the file open for the next reader - see FileStreamPool for why an archive wants this. The pool is shared, so this stream may outlive the archive that created it; the pool then simply closes with the last stream.