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/lldiskcache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llfilesystem/lldiskcache.cpp') 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 -- 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/lldiskcache.cpp | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'indra/llfilesystem/lldiskcache.cpp') 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/lldiskcache.cpp | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'indra/llfilesystem/lldiskcache.cpp') 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