diff options
Diffstat (limited to 'indra/llfilesystem')
-rw-r--r-- | indra/llfilesystem/lldir.cpp | 18 | ||||
-rw-r--r-- | indra/llfilesystem/lldir.h | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_linux.cpp | 4 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_mac.cpp | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_mac.h | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_utils_objc.h | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_utils_objc.mm | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_win32.cpp | 13 | ||||
-rw-r--r-- | indra/llfilesystem/lldir_win32.h | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lldiskcache.cpp | 6 | ||||
-rw-r--r-- | indra/llfilesystem/llfilesystem.cpp | 49 | ||||
-rw-r--r-- | indra/llfilesystem/llfilesystem.h | 12 | ||||
-rw-r--r-- | indra/llfilesystem/lllfsthread.cpp | 2 | ||||
-rw-r--r-- | indra/llfilesystem/lllfsthread.h | 4 |
14 files changed, 63 insertions, 57 deletions
diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index cbf4c1ffb8..a18dc0a4f1 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -201,15 +201,15 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) boost::filesystem::path dir_path(dir_name); #endif - if (boost::filesystem::exists (dir_path)) + if (boost::filesystem::exists(dir_path)) { - if (!boost::filesystem::is_empty (dir_path)) + if (!boost::filesystem::is_empty(dir_path)) { // Directory has content - num_deleted = boost::filesystem::remove_all (dir_path); + num_deleted = (U32)boost::filesystem::remove_all(dir_path); } else { // Directory is empty - boost::filesystem::remove (dir_path); + boost::filesystem::remove(dir_path); } } } @@ -638,7 +638,7 @@ std::string LLDir::getBaseFileName(const std::string& filepath, bool strip_exten std::string LLDir::getDirName(const std::string& filepath) const { std::size_t offset = filepath.find_last_of(getDirDelimiter()); - S32 len = (offset == std::string::npos) ? 0 : offset; + auto len = (offset == std::string::npos) ? 0 : offset; std::string dirname = filepath.substr(0, len); return dirname; } @@ -876,15 +876,15 @@ std::string LLDir::getTempFilename() const } // static -std::string LLDir::getScrubbedFileName(const std::string uncleanFileName) +std::string LLDir::getScrubbedFileName(std::string_view uncleanFileName) { std::string name(uncleanFileName); const std::string illegalChars(getForbiddenFileChars()); // replace any illegal file chars with and underscore '_' - for( unsigned int i = 0; i < illegalChars.length(); i++ ) + for (const char& ch : illegalChars) { - int j = -1; - while((j = name.find(illegalChars[i])) > -1) + std::string::size_type j{ 0 }; + while ((j = name.find(ch, j)) != std::string::npos) { name[j] = '_'; } diff --git a/indra/llfilesystem/lldir.h b/indra/llfilesystem/lldir.h index be82f55e46..b0d2b6aada 100644 --- a/indra/llfilesystem/lldir.h +++ b/indra/llfilesystem/lldir.h @@ -178,7 +178,7 @@ class LLDir static std::string getDumpLogsDirPath(const std::string &file_name = ""); // For producing safe download file names from potentially unsafe ones - static std::string getScrubbedFileName(const std::string uncleanFileName); + static std::string getScrubbedFileName(std::string_view uncleanFileName); static std::string getForbiddenFileChars(); void setDumpDir( const std::string& path ); diff --git a/indra/llfilesystem/lldir_linux.cpp b/indra/llfilesystem/lldir_linux.cpp index cc951ec4b9..b13b42c954 100644 --- a/indra/llfilesystem/lldir_linux.cpp +++ b/indra/llfilesystem/lldir_linux.cpp @@ -247,11 +247,11 @@ bool LLDir_Linux::fileExists(const std::string &filename) const int res = stat(filename.c_str(), &stat_data); if (!res) { - return TRUE; + return true; } else { - return FALSE; + return false; } } diff --git a/indra/llfilesystem/lldir_mac.cpp b/indra/llfilesystem/lldir_mac.cpp index b9560c8234..b9be75c528 100644 --- a/indra/llfilesystem/lldir_mac.cpp +++ b/indra/llfilesystem/lldir_mac.cpp @@ -1,6 +1,6 @@ /** * @file lldir_mac.cpp - * @brief Implementation of directory utilities for Mac OS X + * @brief Implementation of directory utilities for macOS * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/llfilesystem/lldir_mac.h b/indra/llfilesystem/lldir_mac.h index dbb8d85e81..f812ee810b 100644 --- a/indra/llfilesystem/lldir_mac.h +++ b/indra/llfilesystem/lldir_mac.h @@ -1,6 +1,6 @@ /** * @file lldir_mac.h - * @brief Definition of directory utilities class for Mac OS X + * @brief Definition of directory utilities class for macOS * * $LicenseInfo:firstyear=2000&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/llfilesystem/lldir_utils_objc.h b/indra/llfilesystem/lldir_utils_objc.h index 142933972a..1d9cb34e19 100644 --- a/indra/llfilesystem/lldir_utils_objc.h +++ b/indra/llfilesystem/lldir_utils_objc.h @@ -1,6 +1,6 @@ /** * @file lldir_utils_objc.h - * @brief Definition of directory utilities class for Mac OS X + * @brief Definition of directory utilities class for macOS * * $LicenseInfo:firstyear=2020&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/llfilesystem/lldir_utils_objc.mm b/indra/llfilesystem/lldir_utils_objc.mm index 20540fb93c..01fe9e1f2c 100644 --- a/indra/llfilesystem/lldir_utils_objc.mm +++ b/indra/llfilesystem/lldir_utils_objc.mm @@ -1,6 +1,6 @@ /** * @file lldir_utils_objc.mm - * @brief Cocoa implementation of directory utilities for Mac OS X + * @brief Cocoa implementation of directory utilities for macOS * * $LicenseInfo:firstyear=2020&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/llfilesystem/lldir_win32.cpp b/indra/llfilesystem/lldir_win32.cpp index 5c85f0d3d4..a607c70b44 100644 --- a/indra/llfilesystem/lldir_win32.cpp +++ b/indra/llfilesystem/lldir_win32.cpp @@ -47,14 +47,16 @@ DWORD GetDllVersion(LPCTSTR lpszDllName); namespace { // anonymous - enum class prst { INIT, OPEN, SKIP } state = prst::INIT; + enum class prst { INIT, OPEN, SKIP }; + prst state{ prst::INIT }; + // This is called so early that we can't count on static objects being // properly constructed yet, so declare a pointer instead of an instance. std::ofstream* prelogf = nullptr; void prelog(const std::string& message) { - boost::optional<std::string> prelog_name; + std::optional<std::string> prelog_name; switch (state) { @@ -75,6 +77,7 @@ namespace (*prelogf) << "========================================================================" << std::endl; // fall through, don't break + [[fallthrough]]; case prst::OPEN: (*prelogf) << message << std::endl; @@ -230,7 +233,7 @@ LLDir_Win32::LLDir_Win32() { w_str[size] = '\0'; mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); - S32 path_end = mExecutablePathAndName.find_last_of('\\'); + auto path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { mExecutableDir = mExecutablePathAndName.substr(0, path_end); @@ -379,11 +382,11 @@ bool LLDir_Win32::fileExists(const std::string &filename) const int res = LLFile::stat(filename, &stat_data); if (!res) { - return TRUE; + return true; } else { - return FALSE; + return false; } } diff --git a/indra/llfilesystem/lldir_win32.h b/indra/llfilesystem/lldir_win32.h index 2830364f15..ab2726f1a0 100644 --- a/indra/llfilesystem/lldir_win32.h +++ b/indra/llfilesystem/lldir_win32.h @@ -50,7 +50,7 @@ public: /*virtual*/ std::string getLLPluginFilename(std::string base_name); private: - void* mDirSearch_h; + void* mDirSearch_h{ nullptr }; llutf16string mCurrentDir; }; diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 54e49ebcb8..86b1e2ac81 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -222,6 +222,8 @@ const std::string LLDiskCache::assetTypeToString(LLAssetType::EType at) { LLAssetType::AT_MESH, "MESH" }, { LLAssetType::AT_SETTINGS, "SETTINGS" }, { LLAssetType::AT_MATERIAL, "MATERIAL" }, + { LLAssetType::AT_GLTF, "GLTF" }, + { LLAssetType::AT_GLTF_BIN, "GLTF_BIN" }, { LLAssetType::AT_UNKNOWN, "UNKNOWN" } }; @@ -323,8 +325,8 @@ const std::string LLDiskCache::getCacheInfo() { std::ostringstream cache_info; - F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0 * 1024.0); - F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0; + F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0f * 1024.0f); + F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0f; cache_info << std::fixed; cache_info << std::setprecision(1); diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 4c836c8838..7d2a6bd6f5 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -79,6 +79,7 @@ LLFileSystem::~LLFileSystem() // static bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType file_type) { + LL_PROFILE_ZONE_SCOPED; std::string id_str; file_id.toString(id_str); const std::string extra_info = ""; @@ -124,14 +125,14 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp if (LLFile::rename(old_filename, new_filename) != 0) { - // We would like to return FALSE here indicating the operation + // We would like to return false here indicating the operation // failed but the original code does not and doing so seems to // break a lot of things so we go with the flow... - //return FALSE; + //return false; LL_WARNS() << "Failed to rename " << old_file_id << " to " << new_id_str << " reason: " << strerror(errno) << LL_ENDL; } - return TRUE; + return true; } // static @@ -147,15 +148,15 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi if (file.is_open()) { file.seekg(0, std::ios::end); - file_size = file.tellg(); + file_size = (S32)file.tellg(); } return file_size; } -BOOL LLFileSystem::read(U8* buffer, S32 bytes) +bool LLFileSystem::read(U8* buffer, S32 bytes) { - BOOL success = FALSE; + bool success = false; std::string id; mFileID.toString(id); @@ -175,7 +176,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes) } else { - mBytesRead = file.gcount(); + mBytesRead = (S32)file.gcount(); } file.close(); @@ -183,7 +184,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes) mPosition += mBytesRead; if (mBytesRead) { - success = TRUE; + success = true; } } @@ -195,19 +196,19 @@ S32 LLFileSystem::getLastBytesRead() return mBytesRead; } -BOOL LLFileSystem::eof() +bool LLFileSystem::eof() { return mPosition >= getSize(); } -BOOL LLFileSystem::write(const U8* buffer, S32 bytes) +bool LLFileSystem::write(const U8* buffer, S32 bytes) { std::string id_str; mFileID.toString(id_str); const std::string extra_info = ""; const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, mFileType, extra_info); - BOOL success = FALSE; + bool success = false; if (mMode == APPEND) { @@ -216,9 +217,9 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) { ofs.write((const char*)buffer, bytes); - mPosition = ofs.tellp(); // <FS:Ansariel> Fix asset caching + mPosition = (S32)ofs.tellp(); // <FS:Ansariel> Fix asset caching - success = TRUE; + success = true; } } // <FS:Ansariel> Fix asset caching @@ -231,7 +232,7 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) ofs.seekp(mPosition, std::ios::beg); ofs.write((const char*)buffer, bytes); mPosition += bytes; - success = TRUE; + success = true; } else { @@ -241,7 +242,7 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) { ofs.write((const char*)buffer, bytes); mPosition += bytes; - success = TRUE; + success = true; } } } @@ -255,14 +256,14 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) mPosition += bytes; - success = TRUE; + success = true; } } return success; } -BOOL LLFileSystem::seek(S32 offset, S32 origin) +bool LLFileSystem::seek(S32 offset, S32 origin) { if (-1 == origin) { @@ -278,18 +279,18 @@ BOOL LLFileSystem::seek(S32 offset, S32 origin) LL_WARNS() << "Attempt to seek past end of file" << LL_ENDL; mPosition = size; - return FALSE; + return false; } else if (new_pos < 0) { LL_WARNS() << "Attempt to seek past beginning of file" << LL_ENDL; mPosition = 0; - return FALSE; + return false; } mPosition = new_pos; - return TRUE; + return true; } S32 LLFileSystem::tell() const @@ -308,19 +309,19 @@ S32 LLFileSystem::getMaxSize() return INT_MAX; } -BOOL LLFileSystem::rename(const LLUUID& new_id, const LLAssetType::EType new_type) +bool LLFileSystem::rename(const LLUUID& new_id, const LLAssetType::EType new_type) { LLFileSystem::renameFile(mFileID, mFileType, new_id, new_type); mFileID = new_id; mFileType = new_type; - return TRUE; + return true; } -BOOL LLFileSystem::remove() +bool LLFileSystem::remove() { LLFileSystem::removeFile(mFileID, mFileType); - return TRUE; + return true; } diff --git a/indra/llfilesystem/llfilesystem.h b/indra/llfilesystem/llfilesystem.h index d934a408c2..ea1b9cf3a1 100644 --- a/indra/llfilesystem/llfilesystem.h +++ b/indra/llfilesystem/llfilesystem.h @@ -40,18 +40,18 @@ class LLFileSystem LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_type, S32 mode = LLFileSystem::READ); ~LLFileSystem(); - BOOL read(U8* buffer, S32 bytes); + bool read(U8* buffer, S32 bytes); S32 getLastBytesRead(); - BOOL eof(); + bool eof(); - BOOL write(const U8* buffer, S32 bytes); - BOOL seek(S32 offset, S32 origin = -1); + bool write(const U8* buffer, S32 bytes); + bool seek(S32 offset, S32 origin = -1); S32 tell() const; S32 getSize(); S32 getMaxSize(); - BOOL rename(const LLUUID& new_id, const LLAssetType::EType new_type); - BOOL remove(); + bool rename(const LLUUID& new_id, const LLAssetType::EType new_type); + bool remove(); static bool getExists(const LLUUID& file_id, const LLAssetType::EType file_type); static bool removeFile(const LLUUID& file_id, const LLAssetType::EType file_type, int suppress_error = 0); diff --git a/indra/llfilesystem/lllfsthread.cpp b/indra/llfilesystem/lllfsthread.cpp index 7d135b4472..6a882f64a8 100644 --- a/indra/llfilesystem/lllfsthread.cpp +++ b/indra/llfilesystem/lllfsthread.cpp @@ -45,7 +45,7 @@ void LLLFSThread::initClass(bool local_is_threaded) //static S32 LLLFSThread::updateClass(U32 ms_elapsed) { - return sLocal->update((F32)ms_elapsed); + return static_cast<S32>(sLocal->update((F32)ms_elapsed)); } //static diff --git a/indra/llfilesystem/lllfsthread.h b/indra/llfilesystem/lllfsthread.h index 3230c0c2ae..c0ed1931bb 100644 --- a/indra/llfilesystem/lllfsthread.h +++ b/indra/llfilesystem/lllfsthread.h @@ -114,7 +114,7 @@ public: //------------------------------------------------------------------------ public: - LLLFSThread(bool threaded = TRUE); + LLLFSThread(bool threaded = true); ~LLLFSThread(); // Return a Request handle @@ -126,7 +126,7 @@ public: Responder* responder); // static initializers - static void initClass(bool local_is_threaded = TRUE); // Setup sLocal + static void initClass(bool local_is_threaded = true); // Setup sLocal static S32 updateClass(U32 ms_elapsed); static void cleanupClass(); // Delete sLocal |