diff options
| author | Frederick Martian <fredmartian@gmail.com> | 2025-12-09 22:11:14 +0100 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-12-10 20:33:58 +0200 |
| commit | 4153d676839aff0055937d346fcee995f62083f7 (patch) | |
| tree | 964fe3cd954cf941c208d8bd3bce0a54265327c0 /indra/llcommon/llfile.cpp | |
| parent | 9aff5ff403ab8bba071c7a5c75b664399fbfe482 (diff) | |
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
Diffstat (limited to 'indra/llcommon/llfile.cpp')
| -rwxr-xr-x | indra/llcommon/llfile.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
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; |
