From a9d8174b3f61c02466afbf9ae4e771353867e380 Mon Sep 17 00:00:00 2001 From: Danilo Date: Sat, 9 Nov 2024 17:43:57 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20fun=C3=A7=C3=A3o=20SetLength=20em=20?= =?UTF-8?q?Stream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/xna/csharp/stream.hpp | 12 ++++++++++++ sources/framework/csharp/stream.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/xna/csharp/stream.hpp b/includes/xna/csharp/stream.hpp index 05e707a..b8d6e97 100644 --- a/includes/xna/csharp/stream.hpp +++ b/includes/xna/csharp/stream.hpp @@ -62,6 +62,9 @@ namespace xna { //Gets or sets the position within the current stream. 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 virtual void Close() = 0; //Sets the position within the current stream. @@ -108,6 +111,11 @@ namespace xna { return _length; } + virtual constexpr void SetLength(int64_t value) override { + _buffer.reserve(value); + _length = value; + } + virtual constexpr int64_t Position() override { if (_closed) return 0; @@ -152,6 +160,10 @@ namespace xna { virtual int64_t Length() override; virtual int64_t Position() override; + virtual constexpr void SetLength(int64_t value) override { + Exception::Throw(Exception::NOT_IMPLEMENTED); + } + inline virtual void Close() override { _closed = true; diff --git a/sources/framework/csharp/stream.cpp b/sources/framework/csharp/stream.cpp index ac0a9f3..4f35821 100644 --- a/sources/framework/csharp/stream.cpp +++ b/sources/framework/csharp/stream.cpp @@ -88,7 +88,7 @@ namespace xna { auto i = _position + count; if (i < 0 || i > _length) { - return; + Exception::Throw("i < 0 || i > _length"); } if (count <= 8) {