From 53cae8b21f0f77fbb1be22c64deee9b6a3f237f7 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 11 Dec 2020 16:42:10 +0200 Subject: SL-14505 FIXED [Win10] The viewer isn't started on the non-English system locale --- indra/llfilesystem/lldiskcache.cpp | 34 +++++++++++++++++++++++++++------- indra/llfilesystem/llfilesystem.cpp | 16 +++++++--------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 91fc1b15d1..34ff80b250 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -48,7 +48,7 @@ LLDiskCache::LLDiskCache(const std::string cache_dir, { mCacheFilenamePrefix = "sl_cache"; - boost::filesystem::create_directory(cache_dir); + LLFile::mkdir(cache_dir); } void LLDiskCache::purge() @@ -63,9 +63,14 @@ void LLDiskCache::purge() typedef std::pair> file_info_t; std::vector file_info; - if (boost::filesystem::is_directory(mCacheDir)) +#if LL_WINDOWS + std::wstring cache_path(utf8str_to_utf16str(mCacheDir)); +#else + std::string cache_path(mCacheDir); +#endif + if (boost::filesystem::is_directory(cache_path)) { - for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(mCacheDir), {})) + for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_path), {})) { if (boost::filesystem::is_regular_file(entry)) { @@ -201,7 +206,12 @@ const std::string LLDiskCache::metaDataToFilepath(const std::string id, void LLDiskCache::updateFileAccessTime(const std::string file_path) { const std::time_t file_time = std::time(nullptr); + +#if LL_WINDOWS + boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), file_time); +#else boost::filesystem::last_write_time(file_path, file_time); +#endif } const std::string LLDiskCache::getCacheInfo() @@ -227,9 +237,14 @@ void LLDiskCache::clearCache() * the component files but it's called infrequently so it's * likely just fine */ - if (boost::filesystem::is_directory(mCacheDir)) +#if LL_WINDOWS + std::wstring cache_path(utf8str_to_utf16str(mCacheDir)); +#else + std::string cache_path(mCacheDir); +#endif + if (boost::filesystem::is_directory(cache_path)) { - for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(mCacheDir), {})) + for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_path), {})) { if (boost::filesystem::is_regular_file(entry)) { @@ -255,9 +270,14 @@ 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. */ - if (boost::filesystem::is_directory(dir)) +#if LL_WINDOWS + std::wstring dir_path(utf8str_to_utf16str(dir)); +#else + std::string dir_path(dir); +#endif + if (boost::filesystem::is_directory(dir_path)) { - for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(dir), {})) + for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(dir_path), {})) { if (boost::filesystem::is_regular_file(entry)) { diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 932ef2a9c6..64e0b9f193 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -34,8 +34,6 @@ #include "llfasttimer.h" #include "lldiskcache.h" -#include - const S32 LLFileSystem::READ = 0x00000001; const S32 LLFileSystem::WRITE = 0x00000002; const S32 LLFileSystem::READ_WRITE = 0x00000003; // LLFileSystem::READ & LLFileSystem::WRITE @@ -64,7 +62,7 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil const std::string extra_info = ""; const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); - std::ifstream file(filename, std::ios::binary); + llifstream file(filename, std::ios::binary); if (file.is_open()) { file.seekg(0, std::ios::end); @@ -81,7 +79,7 @@ bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType fi const std::string extra_info = ""; const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); - std::remove(filename.c_str()); + LLFile::remove(filename.c_str()); return true; } @@ -102,7 +100,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp // Rename needs the new file to not exist. LLFileSystem::removeFile(new_file_id, new_file_type); - if (std::rename(old_filename.c_str(), new_filename.c_str())) + if (LLFile::rename(old_filename, new_filename) != 0) { // We would like to return FALSE here indicating the operation // failed but the original code does not and doing so seems to @@ -123,7 +121,7 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); S32 file_size = 0; - std::ifstream file(filename, std::ios::binary); + llifstream file(filename, std::ios::binary); if (file.is_open()) { file.seekg(0, std::ios::end); @@ -142,7 +140,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes) const std::string extra_info = ""; const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id, mFileType, extra_info); - std::ifstream file(filename, std::ios::binary); + llifstream file(filename, std::ios::binary); if (file.is_open()) { file.seekg(mPosition, std::ios::beg); @@ -197,7 +195,7 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) if (mMode == APPEND) { - std::ofstream ofs(filename, std::ios::app | std::ios::binary); + llofstream ofs(filename, std::ios::app | std::ios::binary); if (ofs) { ofs.write((const char*)buffer, bytes); @@ -207,7 +205,7 @@ BOOL LLFileSystem::write(const U8* buffer, S32 bytes) } else { - std::ofstream ofs(filename, std::ios::binary); + llofstream ofs(filename, std::ios::binary); if (ofs) { ofs.write((const char*)buffer, bytes); -- cgit v1.2.3