diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 2053d818d90cac5e12293c34f426ab21e74f316f..357932fc1d310aa22973c0111882cf7dd5f948e5 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -179,11 +179,12 @@ const std::string LLDiskCache::assetTypeToString(LLAssetType::EType at) return std::string("UNKNOWN"); } -const std::string LLDiskCache::metaDataToFilepath(const std::string id, - LLAssetType::EType at, - const std::string extra_info) +const std::string LLDiskCache::metaDataToFilepath(const LLUUID& id, + LLAssetType::EType at) { - return llformat("%s%s%s_%s_%s", mCacheDir.c_str(), gDirUtilp->getDirDelimiter().c_str(), mCacheFilenamePrefix.c_str(), id.c_str(), (extra_info.empty() ? "0" : extra_info.c_str())); + std::string uuidstr; + id.toString(uuidstr); + return llformat("%s%s%s_%s", mCacheDir.c_str(), gDirUtilp->getDirDelimiter().c_str(), mCacheFilenamePrefix.c_str(), uuidstr.c_str()); } void LLDiskCache::updateFileAccessTime(const std::string file_path) @@ -250,9 +251,9 @@ void LLDiskCache::clearCache() * likely just fine */ #if LL_WINDOWS - std::wstring cache_path(ll_convert_string_to_wide(mCacheDir)); + boost::filesystem::path cache_path(ll_convert_string_to_wide(mCacheDir)); #else - std::string cache_path(mCacheDir); + boost::filesystem::path cache_path(mCacheDir); #endif if (boost::filesystem::is_directory(cache_path)) { @@ -283,9 +284,9 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) * is an easy win. */ #if LL_WINDOWS - std::wstring dir_path(ll_convert_string_to_wide(dir)); + boost::filesystem::path dir_path(ll_convert_string_to_wide(dir)); #else - std::string dir_path(dir); + boost::filesystem::path dir_path(dir); #endif if (boost::filesystem::is_directory(dir_path)) { diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index 997884da319c8d4ecb53ca427c8ad6ea5fa9a827..ce859ec6bf13aa512f103d8dde06f1b28bc9aad4 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -104,9 +104,8 @@ class LLDiskCache : * so many things had to be pushed back there to accomodate it, that I * decided to move it here. Still not sure that's completely right. */ - const std::string metaDataToFilepath(const std::string id, - LLAssetType::EType at, - const std::string extra_info); + const std::string metaDataToFilepath(const LLUUID& id, + LLAssetType::EType at); /** * Update the "last write time" of a file to "now". This must be called whenever a diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index b1df0847f0d578db40b91e43f6fd1a9b2c007fe8..5a5af8d51360a8ac3c6beb20b49617bee453aec4 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -48,10 +48,7 @@ LLFileSystem::LLFileSystem(const LLUUID& file_id, const LLAssetType::EType file_ // static bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType file_type) { - std::string id_str; - file_id.toString(id_str); - const std::string extra_info = ""; - const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); + const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(file_id, file_type); llifstream file(filename, std::ios::binary); if (file.is_open()) @@ -65,10 +62,7 @@ bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType fil // static bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType file_type) { - std::string id_str; - file_id.toString(id_str); - const std::string extra_info = ""; - const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); + const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(file_id, file_type); LLFile::remove(filename.c_str()); @@ -79,14 +73,8 @@ bool LLFileSystem::removeFile(const LLUUID& file_id, const LLAssetType::EType fi bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::EType old_file_type, const LLUUID& new_file_id, const LLAssetType::EType new_file_type) { - std::string old_id_str; - old_file_id.toString(old_id_str); - const std::string extra_info = ""; - const std::string old_filename = LLDiskCache::getInstance()->metaDataToFilepath(old_id_str, old_file_type, extra_info); - - std::string new_id_str; - new_file_id.toString(new_id_str); - const std::string new_filename = LLDiskCache::getInstance()->metaDataToFilepath(new_id_str, new_file_type, extra_info); + const std::string old_filename = LLDiskCache::getInstance()->metaDataToFilepath(old_file_id, old_file_type); + const std::string new_filename = LLDiskCache::getInstance()->metaDataToFilepath(new_file_id, new_file_type); // Rename needs the new file to not exist. LLFileSystem::removeFile(new_file_id, new_file_type); @@ -97,7 +85,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp // 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; - LL_WARNS() << "Failed to rename " << old_file_id << " to " << new_id_str << " reason: " << strerror(errno) << LL_ENDL; + LL_WARNS() << "Failed to rename " << old_file_id << " to " << new_file_id << " reason: " << strerror(errno) << LL_ENDL; } return TRUE; @@ -106,10 +94,7 @@ bool LLFileSystem::renameFile(const LLUUID& old_file_id, const LLAssetType::ETyp // static S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType file_type) { - std::string id_str; - file_id.toString(id_str); - const std::string extra_info = ""; - const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id_str, file_type, extra_info); + const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(file_id, file_type); S32 file_size = 0; llifstream file(filename, std::ios::binary); @@ -126,10 +111,7 @@ BOOL LLFileSystem::read(U8* buffer, S32 bytes) { BOOL success = TRUE; - std::string id; - mFileID.toString(id); - const std::string extra_info = ""; - const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(id, mFileType, extra_info); + const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(mFileID, mFileType); llifstream file(filename, std::ios::binary); if (file.is_open()) @@ -177,10 +159,7 @@ BOOL LLFileSystem::eof() 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); + const std::string filename = LLDiskCache::getInstance()->metaDataToFilepath(mFileID, mFileType); BOOL success = FALSE;