SL-14505 FIXED [Win10] The viewer isn't started on the non-English system locale

master
Mnikolenko Productengine 2020-12-11 16:42:10 +02:00
parent 08b4b73f6c
commit 53cae8b21f
2 changed files with 34 additions and 16 deletions

View File

@ -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<std::time_t, std::pair<uintmax_t, std::string>> file_info_t;
std::vector<file_info_t> 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))
{

View File

@ -34,8 +34,6 @@
#include "llfasttimer.h"
#include "lldiskcache.h"
#include <fstream>
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);