1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Adiciona função SetLength em Stream

This commit is contained in:
Danilo 2024-11-09 17:43:57 -03:00
parent f151932043
commit a9d8174b3f
2 changed files with 13 additions and 1 deletions

View File

@ -62,6 +62,9 @@ namespace xna {
//Gets or sets the position within the current stream. //Gets or sets the position within the current stream.
virtual void Position(int64_t value) { Seek(value, SeekOrigin::Begin); } virtual void Position(int64_t value) { Seek(value, SeekOrigin::Begin); }
//When overridden in a derived class, sets the length of the current stream.
virtual void SetLength(int64_t value) = 0;
//Closes the current stream and releases any resources //Closes the current stream and releases any resources
virtual void Close() = 0; virtual void Close() = 0;
//Sets the position within the current stream. //Sets the position within the current stream.
@ -108,6 +111,11 @@ namespace xna {
return _length; return _length;
} }
virtual constexpr void SetLength(int64_t value) override {
_buffer.reserve(value);
_length = value;
}
virtual constexpr int64_t Position() override { virtual constexpr int64_t Position() override {
if (_closed) if (_closed)
return 0; return 0;
@ -152,6 +160,10 @@ namespace xna {
virtual int64_t Length() override; virtual int64_t Length() override;
virtual int64_t Position() override; virtual int64_t Position() override;
virtual constexpr void SetLength(int64_t value) override {
Exception::Throw(Exception::NOT_IMPLEMENTED);
}
inline virtual void Close() override { inline virtual void Close() override {
_closed = true; _closed = true;

View File

@ -88,7 +88,7 @@ namespace xna {
auto i = _position + count; auto i = _position + count;
if (i < 0 || i > _length) { if (i < 0 || i > _length) {
return; Exception::Throw("i < 0 || i > _length");
} }
if (count <= 8) { if (count <= 8) {