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:
@@ -94,7 +94,25 @@ LLDir_Linux::LLDir_Linux()
|
||||
mExecutablePathAndName = "";
|
||||
mExecutableDir = tmp_str;
|
||||
mWorkingDir = tmp_str;
|
||||
#ifdef APP_RO_DATA_DIR
|
||||
mAppRODataDir = APP_RO_DATA_DIR;
|
||||
#else
|
||||
mAppRODataDir = tmp_str;
|
||||
#endif
|
||||
std::string::size_type build_dir_pos = mExecutableDir.rfind("/indra/viewer-linux-");
|
||||
if (build_dir_pos != std::string::npos)
|
||||
{
|
||||
// ...we're in a dev checkout
|
||||
mSkinBaseDir = mExecutableDir.substr(0, build_dir_pos) + "/indra/newview/skins";
|
||||
llinfos << "Running in dev checkout with mSkinBaseDir "
|
||||
<< mSkinBaseDir << llendl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ...normal installation running
|
||||
mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins";
|
||||
}
|
||||
|
||||
mOSUserDir = getCurrentUserHome(tmp_str);
|
||||
mOSUserAppDir = "";
|
||||
mLindenUserDir = "";
|
||||
@@ -126,31 +144,6 @@ LLDir_Linux::LLDir_Linux()
|
||||
|
||||
mLLPluginDir = mExecutableDir + mDirDelimiter + "llplugin";
|
||||
|
||||
#ifdef APP_RO_DATA_DIR
|
||||
const char* appRODataDir = APP_RO_DATA_DIR;
|
||||
if(appRODataDir[0] == '/')
|
||||
{
|
||||
// We have a full path to the data directory.
|
||||
mAppRODataDir = appRODataDir;
|
||||
}
|
||||
else if(appRODataDir[0] != '\0')
|
||||
{
|
||||
// We have a relative path to the data directory. Search
|
||||
// for it in each potential install prefix containing the
|
||||
// executable.
|
||||
for(std::string prefix = getDirName(mExecutableDir);
|
||||
!prefix.empty(); prefix = getDirName(prefix))
|
||||
{
|
||||
std::string dir = prefix + "/" + appRODataDir;
|
||||
if(fileExists(dir + "/app_settings"))
|
||||
{
|
||||
mAppRODataDir = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// *TODO: don't use /tmp, use $HOME/.secondlife/tmp or something.
|
||||
mTempDir = "/tmp";
|
||||
}
|
||||
@@ -162,8 +155,15 @@ LLDir_Linux::~LLDir_Linux()
|
||||
// Implementation
|
||||
|
||||
|
||||
void LLDir_Linux::initAppDirs(const std::string &app_name)
|
||||
void LLDir_Linux::initAppDirs(const std::string &app_name,
|
||||
const std::string& app_read_only_data_dir)
|
||||
{
|
||||
// Allow override so test apps can read newview directory
|
||||
if (!app_read_only_data_dir.empty())
|
||||
{
|
||||
mAppRODataDir = app_read_only_data_dir;
|
||||
mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins";
|
||||
}
|
||||
mAppName = app_name;
|
||||
|
||||
std::string upper_app_name(app_name);
|
||||
@@ -226,24 +226,6 @@ void LLDir_Linux::initAppDirs(const std::string &app_name)
|
||||
}
|
||||
}
|
||||
|
||||
res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,""));
|
||||
if (res == -1)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
llwarns << "Couldn't create LL_PATH_MOZILLA_PROFILE dir " << getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"") << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries"));
|
||||
if (res == -1)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
llwarns << "Couldn't create LL_PATH_USER_SETTINGS/dictionaries dir " << getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"") << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem");
|
||||
}
|
||||
|
||||
@@ -266,114 +248,6 @@ U32 LLDir_Linux::countFilesInDir(const std::string &dirname, const std::string &
|
||||
return (file_count);
|
||||
}
|
||||
|
||||
// get the next file in the directory
|
||||
// automatically wrap if we've hit the end
|
||||
BOOL LLDir_Linux::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap)
|
||||
{
|
||||
glob_t g;
|
||||
BOOL result = FALSE;
|
||||
fname = "";
|
||||
|
||||
if(!(dirname == mCurrentDir))
|
||||
{
|
||||
// different dir specified, close old search
|
||||
mCurrentDirIndex = -1;
|
||||
mCurrentDirCount = -1;
|
||||
mCurrentDir = dirname;
|
||||
}
|
||||
|
||||
std::string tmp_str;
|
||||
tmp_str = dirname;
|
||||
tmp_str += mask;
|
||||
|
||||
if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0)
|
||||
{
|
||||
if(g.gl_pathc > 0)
|
||||
{
|
||||
if((int)g.gl_pathc != mCurrentDirCount)
|
||||
{
|
||||
// Number of matches has changed since the last search, meaning a file has been added or deleted.
|
||||
// Reset the index.
|
||||
mCurrentDirIndex = -1;
|
||||
mCurrentDirCount = g.gl_pathc;
|
||||
}
|
||||
|
||||
mCurrentDirIndex++;
|
||||
|
||||
if((mCurrentDirIndex >= (int)g.gl_pathc) && wrap)
|
||||
{
|
||||
mCurrentDirIndex = 0;
|
||||
}
|
||||
|
||||
if(mCurrentDirIndex < (int)g.gl_pathc)
|
||||
{
|
||||
// llinfos << "getNextFileInDir: returning number " << mCurrentDirIndex << ", path is " << g.gl_pathv[mCurrentDirIndex] << llendl;
|
||||
|
||||
// The API wants just the filename, not the full path.
|
||||
//fname = g.gl_pathv[mCurrentDirIndex];
|
||||
|
||||
char *s = strrchr(g.gl_pathv[mCurrentDirIndex], '/');
|
||||
|
||||
if(s == NULL)
|
||||
s = g.gl_pathv[mCurrentDirIndex];
|
||||
else if(s[0] == '/')
|
||||
s++;
|
||||
|
||||
fname = s;
|
||||
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
globfree(&g);
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
// get a random file in the directory
|
||||
// automatically wrap if we've hit the end
|
||||
void LLDir_Linux::getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
|
||||
{
|
||||
S32 num_files;
|
||||
S32 which_file;
|
||||
DIR *dirp;
|
||||
dirent *entryp = NULL;
|
||||
|
||||
fname = "";
|
||||
|
||||
num_files = countFilesInDir(dirname,mask);
|
||||
if (!num_files)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
which_file = ll_rand(num_files);
|
||||
|
||||
// llinfos << "Random select file #" << which_file << llendl;
|
||||
|
||||
// which_file now indicates the (zero-based) index to which file to play
|
||||
|
||||
if (!((dirp = opendir(dirname.c_str()))))
|
||||
{
|
||||
while (which_file--)
|
||||
{
|
||||
if (!((entryp = readdir(dirp))))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!which_file) && entryp)
|
||||
{
|
||||
fname = entryp->d_name;
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
}
|
||||
}
|
||||
|
||||
std::string LLDir_Linux::getCurPath()
|
||||
{
|
||||
char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */
|
||||
|
||||
Reference in New Issue
Block a user