diff options
| author | Frederick Martian <fredmartian@gmail.com> | 2025-12-04 00:10:42 +0100 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-12-10 20:33:58 +0200 |
| commit | 2438854ea33d0a2f8d9fb13d2e3ef6f7d9bda235 (patch) | |
| tree | 473b4284b3941a7b1ea09102e717927f3956bdcd /indra/llfilesystem/llfilesystem.cpp | |
| parent | e0c5fc80c78be6ce16d835a249c9da56c991b226 (diff) | |
Incorporate some of the comment improvements suggested by Copilot and make LLFile::size() return -1 on error and adjust the callers to account for that.
Diffstat (limited to 'indra/llfilesystem/llfilesystem.cpp')
| -rwxr-xr-x | indra/llfilesystem/llfilesystem.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 087daf78be..df8b8de880 100755 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -78,15 +78,21 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type); // not only test for existence but for the file to be not empty - return LLFile::size(filename) > 0; + S64 size = LLFile::size(filename); + if (size < 0) + { + LL_WARNS() << "Failed to get size for file '" << filename << "': " << strerror(errno) << LL_ENDL; + return false; + } + return size > 0; } // static -bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType file_type, int suppress_error /*= 0*/) +bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType file_type, int suppress_warning /*= 0*/) { const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type); - LLFile::remove(filename.c_str(), suppress_error); + LLFile::remove(filename.c_str(), suppress_warning); return true; } @@ -111,11 +117,10 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp } // static -S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType file_type) +S64 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType file_type) { const std::string filename = LLDiskCache::metaDataToFilepath(file_id, file_type); - S64 fileSize = LLFile::size(filename); - return (fileSize > 0) ? (S32)fileSize : 0; + return LLFile::size(filename); } bool LLFileSystem::read(U8* buffer, S32 bytes) @@ -256,7 +261,7 @@ S32 LLFileSystem::tell() const S32 LLFileSystem::getSize() const { - return LLFileSystem::getFileSize(mFileID, mFileType); + return (S32)LLFileSystem::getFileSize(mFileID, mFileType); } S32 LLFileSystem::getMaxSize() const |
