From 4153d676839aff0055937d346fcee995f62083f7 Mon Sep 17 00:00:00 2001 From: Frederick Martian Date: Tue, 9 Dec 2025 22:11:14 +0100 Subject: Make function documentation more clear about the negative offset value. Improve error checking inside function and add comment about not updating the seek pointer when an offset of 0 is specified --- indra/llcommon/llfile.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/llfile.cpp') diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index 3e469111fa..a1d41cdf73 100755 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -911,16 +911,16 @@ S64 LLFile::read(const std::string& filename, void* buf, S64 offset, S64 nbytes, std::ios_base::openmode omode = LLFile::in | LLFile::binary; LLFile file(filename, omode, ec); - if (file) + if (!ec && (bool)file) { - S64 bytes_read = 0; if (offset > 0) { file.seek(offset, ec); } + // else (offset == 0) file was just opened and should already be at 0. if (!ec) { - bytes_read = file.read(buf, nbytes, ec); + S64 bytes_read = file.read(buf, nbytes, ec); if (!ec) { return bytes_read; @@ -961,16 +961,16 @@ S64 LLFile::write(const std::string& filename, const void* buf, S64 offset, S64 } LLFile file(filename, omode, ec); - if (file) + if (!ec && (bool)file) { - S64 bytes_written = 0; if (offset > 0) { file.seek(offset, ec); } + // else (offset == 0) we are not appending, file was just opened and should already be at 0. if (!ec) { - bytes_written = file.write(buf, nbytes, ec); + S64 bytes_written = file.write(buf, nbytes, ec); if (!ec) { return bytes_written; -- cgit v1.3