Port Viewer 2 indra/llvfs

This introduces some API changes, like the new LLDirIterator,
that causes changes elsewhere.

It also include Log Linden's cache changes that aren't in
viewer-development yet that increase the maximum cache size
to ~10 GB.
This commit is contained in:
Aleric Inglewood
2011-06-06 21:38:58 +02:00
parent b31dd134f6
commit 5d87098bd0
33 changed files with 837 additions and 856 deletions

View File

@@ -41,9 +41,12 @@
#endif
#include "lldir.h"
#include "llerror.h"
#include "lltimer.h" // ms_sleep()
#include "lluuid.h"
#include "lltimer.h"
#include "lldiriterator.h"
#if LL_WINDOWS
#include "lldir_win32.h"
@@ -88,27 +91,38 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
std::string filename;
std::string fullpath;
S32 result;
while (getNextFileInDir(dirname, mask, filename, FALSE))
LLDirIterator iter(dirname, mask);
while (iter.next(filename))
{
if ((filename == ".") || (filename == ".."))
fullpath = dirname;
fullpath += getDirDelimiter();
fullpath += filename;
if(LLFile::isdir(fullpath))
{
// skipping directory traversal filenames
count++;
continue;
}
fullpath = dirname;
fullpath += getDirDelimiter();
fullpath += filename;
S32 retry_count = 0;
while (retry_count < 5)
{
if (0 != LLFile::remove(fullpath))
{
retry_count++;
result = errno;
llwarns << "Problem removing " << fullpath << " - errorcode: "
<< result << " attempt " << retry_count << llendl;
ms_sleep(1000);
if(retry_count >= 5)
{
llwarns << "Failed to remove " << fullpath << llendl ;
return count ;
}
ms_sleep(100);
}
else
{
@@ -117,8 +131,7 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
llwarns << "Successfully removed " << fullpath << llendl;
}
break;
}
retry_count++;
}
}
count++;
}
@@ -126,23 +139,31 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
}
const std::string LLDir::findFile(const std::string &filename,
const std::string searchPath1,
const std::string searchPath2,
const std::string searchPath3) const
const std::string& searchPath1,
const std::string& searchPath2,
const std::string& searchPath3) const
{
std::vector<std::string> search_paths;
search_paths.push_back(searchPath1);
search_paths.push_back(searchPath2);
search_paths.push_back(searchPath3);
return findFile(filename, search_paths);
}
std::vector<std::string>::iterator search_path_iter;
const std::string LLDir::findFile(const std::string& filename, const std::vector<std::string> search_paths) const
{
std::vector<std::string>::const_iterator search_path_iter;
for (search_path_iter = search_paths.begin();
search_path_iter != search_paths.end();
++search_path_iter)
{
if (!search_path_iter->empty())
{
std::string filename_and_path = (*search_path_iter) + getDirDelimiter() + filename;
std::string filename_and_path = (*search_path_iter);
if (!filename.empty())
{
filename_and_path += getDirDelimiter() + filename;
}
if (fileExists(filename_and_path))
{
return filename_and_path;
@@ -289,11 +310,7 @@ const std::string& LLDir::getDefaultSkinDir() const
const std::string LLDir::getSkinBaseDir() const
{
std::string dir = getAppRODataDir();
dir += mDirDelimiter;
dir += "skins";
return dir;
return mSkinBaseDir;
}
const std::string &LLDir::getLLPluginDir() const
@@ -325,25 +342,19 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
prefix += mDirDelimiter;
prefix += "app_settings";
break;
case LL_PATH_CHARACTER:
prefix = getAppRODataDir();
prefix += mDirDelimiter;
prefix += "character";
break;
case LL_PATH_MOTIONS:
prefix = getAppRODataDir();
prefix += mDirDelimiter;
prefix += "motions";
break;
case LL_PATH_HELP:
prefix = "help";
break;
case LL_PATH_CACHE:
prefix = getCacheDir();
prefix = getCacheDir();
break;
case LL_PATH_USER_SETTINGS:
@@ -378,28 +389,34 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
prefix = getSkinDir();
break;
case LL_PATH_SKINS:
prefix = getAppRODataDir();
prefix += mDirDelimiter;
prefix += "skins";
case LL_PATH_DEFAULT_SKIN:
prefix = getDefaultSkinDir();
break;
//case LL_PATH_HTML:
// prefix = getSkinDir();
// prefix += mDirDelimiter;
// prefix += "html";
// break;
case LL_PATH_USER_SKIN:
prefix = getUserSkinDir();
break;
case LL_PATH_MOZILLA_PROFILE:
prefix = getOSUserAppDir();
case LL_PATH_SKINS:
prefix = getSkinBaseDir();
break;
case LL_PATH_LOCAL_ASSETS:
prefix = getAppRODataDir();
prefix += mDirDelimiter;
prefix += "browser_profile";
prefix += "local_assets";
break;
case LL_PATH_EXECUTABLE:
prefix = getExecutableDir();
break;
case LL_PATH_FONTS:
prefix = getAppRODataDir();
prefix += mDirDelimiter;
prefix += "fonts";
break;
default:
llassert(0);
}
@@ -415,6 +432,11 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
filename = subdir1 + mDirDelimiter + filename;
}
if (prefix.empty())
{
llwarns << "prefix is empty, possible bad filename" << llendl;
}
std::string expanded_filename;
if (!filename.empty())
{
@@ -440,7 +462,6 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
}
//llinfos << "*** EXPANDED FILENAME: <" << expanded_filename << ">" << llendl;
return expanded_filename;
}
@@ -496,11 +517,14 @@ std::string LLDir::findSkinnedFilename(const std::string &subdir1, const std::st
std::string subdirs = ((subdir1.empty() ? "" : mDirDelimiter) + subdir1)
+ ((subdir2.empty() ? "" : mDirDelimiter) + subdir2);
std::string found_file = findFile(filename,
getUserSkinDir() + subdirs, // first look in user skin override
getSkinDir() + subdirs, // then in current skin
getDefaultSkinDir() + subdirs); // and last in default skin
std::vector<std::string> search_paths;
search_paths.push_back(getUserSkinDir() + subdirs); // first look in user skin override
search_paths.push_back(getSkinDir() + subdirs); // then in current skin
search_paths.push_back(getDefaultSkinDir() + subdirs); // then default skin
search_paths.push_back(getCacheDir() + subdirs); // and last in preload directory
std::string found_file = findFile(filename, search_paths);
return found_file;
}
@@ -625,9 +649,7 @@ void LLDir::setPerAccountChatLogsDir(const std::string &grid, const std::string
void LLDir::setSkinFolder(const std::string &skin_folder)
{
mSkinDir = getAppRODataDir();
mSkinDir += mDirDelimiter;
mSkinDir += "skins";
mSkinDir = getSkinBaseDir();
mSkinDir += mDirDelimiter;
mSkinDir += skin_folder;
@@ -641,9 +663,7 @@ void LLDir::setSkinFolder(const std::string &skin_folder)
// base skin which is used as fallback for all skinned files
// e.g. c:\program files\secondlife\skins\default
mDefaultSkinDir = getAppRODataDir();
mDefaultSkinDir += mDirDelimiter;
mDefaultSkinDir += "skins";
mDefaultSkinDir = getSkinBaseDir();
mDefaultSkinDir += mDirDelimiter;
mDefaultSkinDir += "default";
}
@@ -688,12 +708,8 @@ void LLDir::dumpCurrentDirectories()
LL_DEBUGS2("AppInit","Directories") << " LindenUserDir: " << getLindenUserDir() << LL_ENDL;
LL_DEBUGS2("AppInit","Directories") << " TempDir: " << getTempDir() << LL_ENDL;
LL_DEBUGS2("AppInit","Directories") << " CAFile: " << getCAFile() << LL_ENDL;
LL_DEBUGS2("AppInit","Directories") << " SkinBaseDir: " << getSkinBaseDir() << LL_ENDL;
LL_DEBUGS2("AppInit","Directories") << " SkinDir: " << getSkinDir() << LL_ENDL;
#if LL_LIBXUL_ENABLED
LL_DEBUGS2("AppInit","Directories") << " HTML Path: " << getExpandedFilename( LL_PATH_HTML, "" ) << llendl;
LL_DEBUGS2("AppInit","Directories") << " Mozilla Profile Path: " << getExpandedFilename( LL_PATH_MOZILLA_PROFILE, "" ) << llendl;
#endif
}