From 234bfb0d1f517638e486b6c8a4262419339bb3ca Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:25:51 +0100 Subject: [PATCH] Use std::streamoff for BinaryIO offset vars --- src/utils/binaryio.cpp | 10 +++++----- src/utils/binaryio.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/binaryio.cpp b/src/utils/binaryio.cpp index 1bb4e1a..4dc675b 100644 --- a/src/utils/binaryio.cpp +++ b/src/utils/binaryio.cpp @@ -118,17 +118,17 @@ std::streampos BinaryIO::TellPut() // Input : offset - // way - //----------------------------------------------------------------------------- -void BinaryIO::SeekGet(const std::streampos offset, const std::ios_base::seekdir way) +void BinaryIO::SeekGet(const std::streamoff offset, const std::ios_base::seekdir way) { assert(IsReadMode()); m_stream.seekg(offset, way); } -void BinaryIO::SeekPut(const std::streampos offset, const std::ios_base::seekdir way) +void BinaryIO::SeekPut(const std::streamoff offset, const std::ios_base::seekdir way) { assert(IsWriteMode()); m_stream.seekp(offset, way); - const std::streampos newOffset = m_stream.tellp(); + const std::streamoff newOffset = m_stream.tellp(); // seekp writes padding when we go beyond eof, therefore we should update // the size in case this happens. @@ -136,7 +136,7 @@ void BinaryIO::SeekPut(const std::streampos offset, const std::ios_base::seekdir m_size = newOffset; } -void BinaryIO::Seek(const std::streampos offset, const std::ios_base::seekdir way) +void BinaryIO::Seek(const std::streamoff offset, const std::ios_base::seekdir way) { if (IsReadMode()) SeekGet(offset, way); @@ -157,7 +157,7 @@ const std::filebuf* BinaryIO::GetData() const // Purpose: returns the data size // Output : std::streampos //----------------------------------------------------------------------------- -const std::streampos BinaryIO::GetSize() const +const std::streamoff BinaryIO::GetSize() const { return m_size; } diff --git a/src/utils/binaryio.h b/src/utils/binaryio.h index b7d36ab..bf1c107 100644 --- a/src/utils/binaryio.h +++ b/src/utils/binaryio.h @@ -24,12 +24,12 @@ class BinaryIO std::streampos TellGet(); std::streampos TellPut(); - void SeekGet(const std::streampos offset, const std::ios_base::seekdir way = std::ios::beg); - void SeekPut(const std::streampos offset, const std::ios_base::seekdir way = std::ios::beg); - void Seek(const std::streampos offset, const std::ios_base::seekdir way = std::ios::beg); + void SeekGet(const std::streamoff offset, const std::ios_base::seekdir way = std::ios::beg); + void SeekPut(const std::streamoff offset, const std::ios_base::seekdir way = std::ios::beg); + void Seek(const std::streamoff offset, const std::ios_base::seekdir way = std::ios::beg); const std::filebuf* GetData() const; - const std::streampos GetSize() const; + const std::streamoff GetSize() const; bool IsReadMode() const; bool IsWriteMode() const; @@ -110,7 +110,7 @@ class BinaryIO private: std::fstream m_stream; // I/O stream. - std::streampos m_size; // File size. + std::streamoff m_size; // File size. std::ios_base::openmode m_flags; // Stream flags. Mode_e m_mode; // Stream mode. };