From 3dbc746dddb10d0426d0db1e28fea66003f4a20d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 28 Nov 2015 11:43:40 -1000 Subject: [PATCH] Proper FileReader::readUBytesToBuf return value --- src/Athena/FileReader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp index 9d3dddb..cdb8fc4 100644 --- a/src/Athena/FileReader.cpp +++ b/src/Athena/FileReader.cpp @@ -176,6 +176,12 @@ atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) return fread(buf, 1, len, m_fileHandle); else { + atUint64 fs = utility::fileSize(m_filename); + if (m_offset >= fs) + return 0; + if (m_offset + len >= fs) + len = fs - m_offset; + size_t block = m_offset / m_blockSize; atUint64 cacheOffset = m_offset % m_blockSize; atUint64 cacheSize;