From 179b29252d8bb28e11686a1852c8e8ffcd98ecc0 Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 11 Feb 2025 05:02:45 -0500 Subject: Rework windows to use zc:wchar_t for better c++ conformance and compatibility with modern libraries --- indra/llfilesystem/lldir.cpp | 4 ++-- indra/llfilesystem/lldir_win32.cpp | 12 ++++++------ indra/llfilesystem/lldir_win32.h | 2 +- indra/llfilesystem/lldirguard.h | 7 +++++-- indra/llfilesystem/lldiriterator.cpp | 2 +- indra/llfilesystem/lldiskcache.cpp | 8 ++++---- indra/llfilesystem/llfilesystem.cpp | 4 ++-- 7 files changed, 21 insertions(+), 18 deletions(-) (limited to 'indra/llfilesystem') diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index 99d4850610..9c61c25ada 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -103,7 +103,7 @@ std::vector LLDir::getFilesInDir(const std::string &dirname) //Returns a vector of fullpath filenames. #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - boost::filesystem::path p(utf8str_to_utf16str(dirname)); + boost::filesystem::path p(ll_convert(dirname)); #else boost::filesystem::path p(dirname); #endif @@ -196,7 +196,7 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) try { #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - boost::filesystem::path dir_path(utf8str_to_utf16str(dir_name)); + boost::filesystem::path dir_path(ll_convert(dir_name)); #else boost::filesystem::path dir_path(dir_name); #endif diff --git a/indra/llfilesystem/lldir_win32.cpp b/indra/llfilesystem/lldir_win32.cpp index a607c70b44..58c080c982 100644 --- a/indra/llfilesystem/lldir_win32.cpp +++ b/indra/llfilesystem/lldir_win32.cpp @@ -172,7 +172,7 @@ LLDir_Win32::LLDir_Win32() { w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } - mTempDir = utf16str_to_utf8str(llutf16string(w_str)); + mTempDir = ll_convert(std::wstring(w_str)); if (mOSUserDir.empty()) { @@ -225,14 +225,14 @@ LLDir_Win32::LLDir_Win32() // Set working directory, for LLDir::getWorkingDir() GetCurrentDirectory(MAX_PATH, w_str); - mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); + mWorkingDir = ll_convert(std::wstring(w_str)); // Set the executable directory S32 size = GetModuleFileName(NULL, w_str, MAX_PATH); if (size) { w_str[size] = '\0'; - mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); + mExecutablePathAndName = ll_convert(std::wstring(w_str)); auto path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { @@ -347,8 +347,8 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string & WIN32_FIND_DATA FileData; - llutf16string pathname = utf8str_to_utf16str(dirname); - pathname += utf8str_to_utf16str(mask); + std::wstring pathname = ll_convert(dirname); + pathname += ll_convert(mask); if ((count_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE) { @@ -370,7 +370,7 @@ std::string LLDir_Win32::getCurPath() WCHAR w_str[MAX_PATH]; GetCurrentDirectory(MAX_PATH, w_str); - return utf16str_to_utf8str(llutf16string(w_str)); + return ll_convert(std::wstring(w_str)); } diff --git a/indra/llfilesystem/lldir_win32.h b/indra/llfilesystem/lldir_win32.h index ab2726f1a0..21a3f1213b 100644 --- a/indra/llfilesystem/lldir_win32.h +++ b/indra/llfilesystem/lldir_win32.h @@ -51,7 +51,7 @@ public: private: void* mDirSearch_h{ nullptr }; - llutf16string mCurrentDir; + std::wstring mCurrentDir; }; #endif // LL_LLDIR_WIN32_H diff --git a/indra/llfilesystem/lldirguard.h b/indra/llfilesystem/lldirguard.h index fcb179bbc8..c6ce13efb4 100644 --- a/indra/llfilesystem/lldirguard.h +++ b/indra/llfilesystem/lldirguard.h @@ -31,6 +31,9 @@ #include "llerror.h" #if LL_WINDOWS + +#include "llwin32headers.h" + class LLDirectoryGuard { public: @@ -46,8 +49,8 @@ public: (wcsncmp(mOrigDir,mFinalDir,mOrigDirLen)!=0)) { // Dir has changed - std::string mOrigDirUtf8 = utf16str_to_utf8str(llutf16string(mOrigDir)); - std::string mFinalDirUtf8 = utf16str_to_utf8str(llutf16string(mFinalDir)); + std::string mOrigDirUtf8 = ll_convert(std::wstring(mOrigDir)); + std::string mFinalDirUtf8 = ll_convert(std::wstring(mFinalDir)); LL_INFOS() << "Resetting working dir from " << mFinalDirUtf8 << " to " << mOrigDirUtf8 << LL_ENDL; SetCurrentDirectory(mOrigDir); } diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp index 61f768c512..e8c37389d2 100644 --- a/indra/llfilesystem/lldiriterator.cpp +++ b/indra/llfilesystem/lldiriterator.cpp @@ -52,7 +52,7 @@ LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask) : mIsValid(false) { #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - fs::path dir_path(utf8str_to_utf16str(dirname)); + fs::path dir_path(ll_convert(dirname)); #else fs::path dir_path(dirname); #endif diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 49904911a9..e971e1885a 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -103,7 +103,7 @@ void LLDiskCache::purge() std::vector file_info; #if LL_WINDOWS - std::wstring cache_path(utf8str_to_utf16str(sCacheDir)); + std::wstring cache_path(ll_convert(sCacheDir)); #else std::string cache_path(sCacheDir); #endif @@ -226,7 +226,7 @@ void LLDiskCache::clearCache() */ boost::system::error_code ec; #if LL_WINDOWS - std::wstring cache_path(utf8str_to_utf16str(sCacheDir)); + std::wstring cache_path(ll_convert(sCacheDir)); #else std::string cache_path(sCacheDir); #endif @@ -259,7 +259,7 @@ void LLDiskCache::removeOldVFSFiles() boost::system::error_code ec; #if LL_WINDOWS - std::wstring cache_path(utf8str_to_utf16str(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""))); + std::wstring cache_path(ll_convert(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""))); #else std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")); #endif @@ -300,7 +300,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir) */ boost::system::error_code ec; #if LL_WINDOWS - std::wstring dir_path(utf8str_to_utf16str(dir)); + std::wstring dir_path(ll_convert(dir)); #else std::string dir_path(dir); #endif diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index c8ce9531c2..5ce5244107 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -316,7 +316,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path) boost::system::error_code ec; #if LL_WINDOWS // file last write time - const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec); + const std::time_t last_write_time = boost::filesystem::last_write_time(ll_convert(file_path), ec); if (ec.failed()) { LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL; @@ -330,7 +330,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path) // before the last one if (delta_time > time_threshold) { - boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec); + boost::filesystem::last_write_time(ll_convert(file_path), cur_time, ec); } #else // file last write time -- cgit v1.2.3 From 3f65a4bfec71a9950a541f9e6195a572a0622b48 Mon Sep 17 00:00:00 2001 From: Rye Date: Fri, 22 Aug 2025 13:13:03 -0400 Subject: Fix test build on macOS --- indra/llfilesystem/tests/lldir_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llfilesystem') diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp index 6e191ad096..d7d57fa86f 100644 --- a/indra/llfilesystem/tests/lldir_test.cpp +++ b/indra/llfilesystem/tests/lldir_test.cpp @@ -435,7 +435,7 @@ namespace tut for (counter=0, foundUnused=false; !foundUnused; counter++ ) { char counterStr[3]; - sprintf(counterStr, "%02d", counter); + snprintf(counterStr, sizeof(counterStr), "%02d", counter); uniqueDir = dirbase + counterStr; foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) ); } -- cgit v1.2.3 From 536c821c091be7020c614857e1fd220203f6ab23 Mon Sep 17 00:00:00 2001 From: Rye Date: Wed, 27 Aug 2025 23:05:40 -0400 Subject: MacOS companion changes for dullahan 1.21 including package structure and linkage fixes --- indra/llfilesystem/lldir_mac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llfilesystem') diff --git a/indra/llfilesystem/lldir_mac.cpp b/indra/llfilesystem/lldir_mac.cpp index b9be75c528..2db1b6ec5d 100644 --- a/indra/llfilesystem/lldir_mac.cpp +++ b/indra/llfilesystem/lldir_mac.cpp @@ -149,7 +149,7 @@ LLDir_Mac::LLDir_Mac() mWorkingDir = getCurPath(); - mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin"; + mLLPluginDir = mAppRODataDir + mDirDelimiter + "SLPlugin.app" + mDirDelimiter + "Contents" + mDirDelimiter + "Frameworks"; } } -- cgit v1.2.3 From 94e45ca2e60b4013a4e38d8f2c1fe8dad4207c3a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 5 Sep 2025 15:09:11 +0300 Subject: Replace boost filesystem with std filesystem Build fixes, instead of resolving unclear boost filesystem errors just updated to std in affected places. --- indra/llfilesystem/lldir.cpp | 32 ++++++++--------- indra/llfilesystem/lldiriterator.cpp | 4 +-- indra/llfilesystem/lldiskcache.cpp | 70 ++++++++++++++++++------------------ 3 files changed, 53 insertions(+), 53 deletions(-) (limited to 'indra/llfilesystem') diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index ea33a3bb90..06f5dd2f77 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -43,7 +43,7 @@ #include "lldiriterator.h" #include "stringize.h" #include "llstring.h" -#include +#include #include #include #include @@ -103,24 +103,24 @@ std::vector LLDir::getFilesInDir(const std::string &dirname) //Returns a vector of fullpath filenames. #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - boost::filesystem::path p(ll_convert(dirname)); + std::filesystem::path p(ll_convert(dirname)); #else - boost::filesystem::path p(dirname); + std::filesystem::path p(dirname); #endif std::vector v; - boost::system::error_code ec; - if (exists(p, ec) && !ec.failed()) + std::error_code ec; + if (std::filesystem::exists(p, ec) && ec.value() == 0) { - if (is_directory(p, ec) && !ec.failed()) + if (is_directory(p, ec) && ec.value() == 0) { - boost::filesystem::directory_iterator end_iter; - for (boost::filesystem::directory_iterator dir_itr(p); + std::filesystem::directory_iterator end_iter; + for (std::filesystem::directory_iterator dir_itr(p); dir_itr != end_iter; ++dir_itr) { - if (boost::filesystem::is_regular_file(dir_itr->status())) + if (std::filesystem::is_regular_file(dir_itr->status())) { v.push_back(dir_itr->path().filename().string()); } @@ -197,24 +197,24 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) try { #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - boost::filesystem::path dir_path(ll_convert(dir_name)); + std::filesystem::path dir_path(ll_convert(dir_name)); #else - boost::filesystem::path dir_path(dir_name); + std::filesystem::path dir_path(dir_name); #endif - if (boost::filesystem::exists(dir_path)) + if (std::filesystem::exists(dir_path)) { - if (!boost::filesystem::is_empty(dir_path)) + if (!std::filesystem::is_empty(dir_path)) { // Directory has content - num_deleted = (U32)boost::filesystem::remove_all(dir_path); + num_deleted = (U32)std::filesystem::remove_all(dir_path); } else { // Directory is empty - boost::filesystem::remove(dir_path); + std::filesystem::remove(dir_path); } } } - catch (boost::filesystem::filesystem_error &er) + catch (std::filesystem::filesystem_error &er) { LL_WARNS() << "Failed to delete " << dir_name << " with error " << er.code().message() << LL_ENDL; } diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp index e8c37389d2..28a93f1446 100644 --- a/indra/llfilesystem/lldiriterator.cpp +++ b/indra/llfilesystem/lldiriterator.cpp @@ -28,9 +28,9 @@ #include "fix_macros.h" #include "llregex.h" -#include +#include -namespace fs = boost::filesystem; +namespace fs = std::filesystem; static std::string glob_to_regex(const std::string& glob); diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index e971e1885a..417577369f 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -34,7 +34,7 @@ #include "llapp.h" #include "llassettype.h" #include "lldir.h" -#include +#include #include #include "lldiskcache.h" @@ -83,7 +83,7 @@ LLDiskCache::LLDiskCache(const std::string& cache_dir, // garbage.) // Other situation: B is trimming the cache and A wants to read a file that is -// about to get deleted. boost::filesystem::remove does whatever it is doing +// about to get deleted. std::filesystem::remove does whatever it is doing // before actually deleting the file. If A opens the file before the file is // actually gone, the OS call from B to delete the file will fail since the OS // will prevent this. B continues with the next file. If the file is already @@ -96,10 +96,10 @@ void LLDiskCache::purge() LL_INFOS() << "Total dir size before purge is " << dirFileSize(sCacheDir) << LL_ENDL; } - boost::system::error_code ec; + std::error_code ec; auto start_time = std::chrono::high_resolution_clock::now(); - typedef std::pair> file_info_t; + typedef std::pair> file_info_t; std::vector file_info; #if LL_WINDOWS @@ -107,23 +107,23 @@ void LLDiskCache::purge() #else std::string cache_path(sCacheDir); #endif - if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) + if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) { - boost::filesystem::directory_iterator iter(cache_path, ec); - while (iter != boost::filesystem::directory_iterator() && !ec.failed()) + std::filesystem::directory_iterator iter(cache_path, ec); + while (iter != std::filesystem::directory_iterator() && ec.value() == 0) { - if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) + if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - uintmax_t file_size = boost::filesystem::file_size(*iter, ec); - if (ec.failed()) + uintmax_t file_size = std::filesystem::file_size(*iter, ec); + if (ec.value() != 0) { continue; } const std::string file_path = (*iter).path().string(); - const std::time_t file_time = boost::filesystem::last_write_time(*iter, ec); - if (ec.failed()) + const std::filesystem::file_time_type file_time = std::filesystem::last_write_time(*iter, ec); + if (ec.value() != 0) { continue; } @@ -159,8 +159,8 @@ void LLDiskCache::purge() } if (should_remove) { - boost::filesystem::remove(entry.second.second, ec); - if (ec.failed()) + std::filesystem::remove(entry.second.second, ec); + if (ec.value() != 0) { LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL; } @@ -224,23 +224,23 @@ void LLDiskCache::clearCache() * the component files but it's called infrequently so it's * likely just fine */ - boost::system::error_code ec; + std::error_code ec; #if LL_WINDOWS std::wstring cache_path(ll_convert(sCacheDir)); #else std::string cache_path(sCacheDir); #endif - if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) + if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) { - boost::filesystem::directory_iterator iter(cache_path, ec); - while (iter != boost::filesystem::directory_iterator() && !ec.failed()) + std::filesystem::directory_iterator iter(cache_path, ec); + while (iter != std::filesystem::directory_iterator() && ec.value() == 0) { - if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) + if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - boost::filesystem::remove(*iter, ec); - if (ec.failed()) + std::filesystem::remove(*iter, ec); + if (ec.value() != 0) { LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL; } @@ -257,24 +257,24 @@ void LLDiskCache::removeOldVFSFiles() static const char CACHE_FORMAT[] = "inv.llsd"; static const char DB_FORMAT[] = "db2.x"; - boost::system::error_code ec; + std::error_code ec; #if LL_WINDOWS std::wstring cache_path(ll_convert(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""))); #else std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")); #endif - if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) + if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) { - boost::filesystem::directory_iterator iter(cache_path, ec); - while (iter != boost::filesystem::directory_iterator() && !ec.failed()) + std::filesystem::directory_iterator iter(cache_path, ec); + while (iter != std::filesystem::directory_iterator() && ec.value() == 0) { - if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) + if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) { if (((*iter).path().string().find(CACHE_FORMAT) != std::string::npos) || ((*iter).path().string().find(DB_FORMAT) != std::string::npos)) { - boost::filesystem::remove(*iter, ec); - if (ec.failed()) + std::filesystem::remove(*iter, ec); + if (ec.value() != 0) { LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL; } @@ -298,23 +298,23 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir) * so if performance is ever an issue, optimizing this or removing it altogether, * is an easy win. */ - boost::system::error_code ec; + std::error_code ec; #if LL_WINDOWS std::wstring dir_path(ll_convert(dir)); #else std::string dir_path(dir); #endif - if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed()) + if (std::filesystem::is_directory(dir_path, ec) && ec.value() == 0) { - boost::filesystem::directory_iterator iter(dir_path, ec); - while (iter != boost::filesystem::directory_iterator() && !ec.failed()) + std::filesystem::directory_iterator iter(dir_path, ec); + while (iter != std::filesystem::directory_iterator() && ec.value() == 0) { - if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) + if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - uintmax_t file_size = boost::filesystem::file_size(*iter, ec); - if (!ec.failed()) + uintmax_t file_size = std::filesystem::file_size(*iter, ec); + if (ec.value() == 0) { total_file_size += file_size; } -- cgit v1.2.3 From 94cfce4a4d2dbc799e5e8a3495a628ae85d4cffe Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Fri, 5 Sep 2025 13:44:57 -0700 Subject: Revert "Replace boost filesystem with std filesystem" This reverts commit 94e45ca2e60b4013a4e38d8f2c1fe8dad4207c3a. --- indra/llfilesystem/lldir.cpp | 32 ++++++++--------- indra/llfilesystem/lldiriterator.cpp | 4 +-- indra/llfilesystem/lldiskcache.cpp | 70 ++++++++++++++++++------------------ 3 files changed, 53 insertions(+), 53 deletions(-) (limited to 'indra/llfilesystem') diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index 06f5dd2f77..ea33a3bb90 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -43,7 +43,7 @@ #include "lldiriterator.h" #include "stringize.h" #include "llstring.h" -#include +#include #include #include #include @@ -103,24 +103,24 @@ std::vector LLDir::getFilesInDir(const std::string &dirname) //Returns a vector of fullpath filenames. #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - std::filesystem::path p(ll_convert(dirname)); + boost::filesystem::path p(ll_convert(dirname)); #else - std::filesystem::path p(dirname); + boost::filesystem::path p(dirname); #endif std::vector v; - std::error_code ec; - if (std::filesystem::exists(p, ec) && ec.value() == 0) + boost::system::error_code ec; + if (exists(p, ec) && !ec.failed()) { - if (is_directory(p, ec) && ec.value() == 0) + if (is_directory(p, ec) && !ec.failed()) { - std::filesystem::directory_iterator end_iter; - for (std::filesystem::directory_iterator dir_itr(p); + boost::filesystem::directory_iterator end_iter; + for (boost::filesystem::directory_iterator dir_itr(p); dir_itr != end_iter; ++dir_itr) { - if (std::filesystem::is_regular_file(dir_itr->status())) + if (boost::filesystem::is_regular_file(dir_itr->status())) { v.push_back(dir_itr->path().filename().string()); } @@ -197,24 +197,24 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) try { #ifdef LL_WINDOWS // or BOOST_WINDOWS_API - std::filesystem::path dir_path(ll_convert(dir_name)); + boost::filesystem::path dir_path(ll_convert(dir_name)); #else - std::filesystem::path dir_path(dir_name); + boost::filesystem::path dir_path(dir_name); #endif - if (std::filesystem::exists(dir_path)) + if (boost::filesystem::exists(dir_path)) { - if (!std::filesystem::is_empty(dir_path)) + if (!boost::filesystem::is_empty(dir_path)) { // Directory has content - num_deleted = (U32)std::filesystem::remove_all(dir_path); + num_deleted = (U32)boost::filesystem::remove_all(dir_path); } else { // Directory is empty - std::filesystem::remove(dir_path); + boost::filesystem::remove(dir_path); } } } - catch (std::filesystem::filesystem_error &er) + catch (boost::filesystem::filesystem_error &er) { LL_WARNS() << "Failed to delete " << dir_name << " with error " << er.code().message() << LL_ENDL; } diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp index 28a93f1446..e8c37389d2 100644 --- a/indra/llfilesystem/lldiriterator.cpp +++ b/indra/llfilesystem/lldiriterator.cpp @@ -28,9 +28,9 @@ #include "fix_macros.h" #include "llregex.h" -#include +#include -namespace fs = std::filesystem; +namespace fs = boost::filesystem; static std::string glob_to_regex(const std::string& glob); diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 417577369f..e971e1885a 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -34,7 +34,7 @@ #include "llapp.h" #include "llassettype.h" #include "lldir.h" -#include +#include #include #include "lldiskcache.h" @@ -83,7 +83,7 @@ LLDiskCache::LLDiskCache(const std::string& cache_dir, // garbage.) // Other situation: B is trimming the cache and A wants to read a file that is -// about to get deleted. std::filesystem::remove does whatever it is doing +// about to get deleted. boost::filesystem::remove does whatever it is doing // before actually deleting the file. If A opens the file before the file is // actually gone, the OS call from B to delete the file will fail since the OS // will prevent this. B continues with the next file. If the file is already @@ -96,10 +96,10 @@ void LLDiskCache::purge() LL_INFOS() << "Total dir size before purge is " << dirFileSize(sCacheDir) << LL_ENDL; } - std::error_code ec; + boost::system::error_code ec; auto start_time = std::chrono::high_resolution_clock::now(); - typedef std::pair> file_info_t; + typedef std::pair> file_info_t; std::vector file_info; #if LL_WINDOWS @@ -107,23 +107,23 @@ void LLDiskCache::purge() #else std::string cache_path(sCacheDir); #endif - if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) + if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) { - std::filesystem::directory_iterator iter(cache_path, ec); - while (iter != std::filesystem::directory_iterator() && ec.value() == 0) + boost::filesystem::directory_iterator iter(cache_path, ec); + while (iter != boost::filesystem::directory_iterator() && !ec.failed()) { - if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) + if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - uintmax_t file_size = std::filesystem::file_size(*iter, ec); - if (ec.value() != 0) + uintmax_t file_size = boost::filesystem::file_size(*iter, ec); + if (ec.failed()) { continue; } const std::string file_path = (*iter).path().string(); - const std::filesystem::file_time_type file_time = std::filesystem::last_write_time(*iter, ec); - if (ec.value() != 0) + const std::time_t file_time = boost::filesystem::last_write_time(*iter, ec); + if (ec.failed()) { continue; } @@ -159,8 +159,8 @@ void LLDiskCache::purge() } if (should_remove) { - std::filesystem::remove(entry.second.second, ec); - if (ec.value() != 0) + boost::filesystem::remove(entry.second.second, ec); + if (ec.failed()) { LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL; } @@ -224,23 +224,23 @@ void LLDiskCache::clearCache() * the component files but it's called infrequently so it's * likely just fine */ - std::error_code ec; + boost::system::error_code ec; #if LL_WINDOWS std::wstring cache_path(ll_convert(sCacheDir)); #else std::string cache_path(sCacheDir); #endif - if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) + if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) { - std::filesystem::directory_iterator iter(cache_path, ec); - while (iter != std::filesystem::directory_iterator() && ec.value() == 0) + boost::filesystem::directory_iterator iter(cache_path, ec); + while (iter != boost::filesystem::directory_iterator() && !ec.failed()) { - if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) + if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - std::filesystem::remove(*iter, ec); - if (ec.value() != 0) + boost::filesystem::remove(*iter, ec); + if (ec.failed()) { LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL; } @@ -257,24 +257,24 @@ void LLDiskCache::removeOldVFSFiles() static const char CACHE_FORMAT[] = "inv.llsd"; static const char DB_FORMAT[] = "db2.x"; - std::error_code ec; + boost::system::error_code ec; #if LL_WINDOWS std::wstring cache_path(ll_convert(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""))); #else std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")); #endif - if (std::filesystem::is_directory(cache_path, ec) && ec.value() == 0) + if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) { - std::filesystem::directory_iterator iter(cache_path, ec); - while (iter != std::filesystem::directory_iterator() && ec.value() == 0) + boost::filesystem::directory_iterator iter(cache_path, ec); + while (iter != boost::filesystem::directory_iterator() && !ec.failed()) { - if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) + if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) { if (((*iter).path().string().find(CACHE_FORMAT) != std::string::npos) || ((*iter).path().string().find(DB_FORMAT) != std::string::npos)) { - std::filesystem::remove(*iter, ec); - if (ec.value() != 0) + boost::filesystem::remove(*iter, ec); + if (ec.failed()) { LL_WARNS() << "Failed to delete cache file " << *iter << ": " << ec.message() << LL_ENDL; } @@ -298,23 +298,23 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir) * so if performance is ever an issue, optimizing this or removing it altogether, * is an easy win. */ - std::error_code ec; + boost::system::error_code ec; #if LL_WINDOWS std::wstring dir_path(ll_convert(dir)); #else std::string dir_path(dir); #endif - if (std::filesystem::is_directory(dir_path, ec) && ec.value() == 0) + if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed()) { - std::filesystem::directory_iterator iter(dir_path, ec); - while (iter != std::filesystem::directory_iterator() && ec.value() == 0) + boost::filesystem::directory_iterator iter(dir_path, ec); + while (iter != boost::filesystem::directory_iterator() && !ec.failed()) { - if (std::filesystem::is_regular_file(*iter, ec) && ec.value() == 0) + if (boost::filesystem::is_regular_file(*iter, ec) && !ec.failed()) { if ((*iter).path().string().find(CACHE_FILENAME_PREFIX) != std::string::npos) { - uintmax_t file_size = std::filesystem::file_size(*iter, ec); - if (ec.value() == 0) + uintmax_t file_size = boost::filesystem::file_size(*iter, ec); + if (!ec.failed()) { total_file_size += file_size; } -- cgit v1.2.3