Portability Mode!
Just add --portable to the shortcut or use the provided shortcut as a template, though it's likely the provided shortcut will not work on other computers, because the drive letter will change
This commit is contained in:
@@ -710,6 +710,33 @@ void LLDir::setLindenUserDir(const std::string &grid, const std::string &first,
|
||||
dumpCurrentDirectories();
|
||||
}
|
||||
|
||||
void LLDir::makePortable()
|
||||
{
|
||||
std::string dir = mExecutableDir;
|
||||
dir.erase(dir.rfind(mDirDelimiter)); // Go one level up
|
||||
dir += mDirDelimiter + "portable_viewer";
|
||||
if (LLFile::mkdir(dir) == -1)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
llwarns << "Couldn't create portable_viewer directory." << llendl;
|
||||
return; // Failed, don't mess anything up.
|
||||
}
|
||||
}
|
||||
mOSUserDir = dir + mDirDelimiter + "settings";
|
||||
mOSCacheDir = dir + mDirDelimiter + "cache";
|
||||
if (LLFile::mkdir(mOSUserDir) == -1 || LLFile::mkdir(mOSCacheDir) == -1)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
{
|
||||
llwarns << "Couldn't create portable_viewer cache and settings directories." << llendl;
|
||||
return; // Failed, don't mess up the existing initialization.
|
||||
}
|
||||
}
|
||||
mDefaultCacheDir = buildSLOSCacheDir();
|
||||
initAppDirs(mAppName); // This is kinda lazy, but it's probably the quickest, most uniform way.
|
||||
}
|
||||
|
||||
void LLDir::setChatLogsDir(const std::string &path)
|
||||
{
|
||||
if (!path.empty() )
|
||||
|
||||
@@ -133,6 +133,7 @@ class LLDir
|
||||
static std::string getForbiddenFileChars();
|
||||
void setDumpDir( const std::string& path );
|
||||
|
||||
void makePortable();
|
||||
virtual void setChatLogsDir(const std::string &path); // Set the chat logs dir to this user's dir
|
||||
virtual void setPerAccountChatLogsDir(const std::string &grid, const std::string &first, const std::string &last); // Set the per user chat log directory.
|
||||
virtual void setLindenUserDir(const std::string& grid, const std::string& first, const std::string& last); // Set the linden user dir to this user's dir
|
||||
|
||||
@@ -253,6 +253,12 @@
|
||||
<string>UserConnectionPort</string>
|
||||
</map>
|
||||
|
||||
<key>portable</key>
|
||||
<map>
|
||||
<key>count</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
|
||||
<key>purge</key>
|
||||
<map>
|
||||
<key>desc</key>
|
||||
|
||||
@@ -805,6 +805,8 @@ CreateShortCut "$DESKTOP\$INSTSHORTCUT.lnk" \
|
||||
"$INSTDIR\$INSTEXE" "$INSTFLAGS $SHORTCUT_LANG_PARAM"
|
||||
CreateShortCut "$INSTDIR\$INSTSHORTCUT.lnk" \
|
||||
"$INSTDIR\$INSTEXE" "$INSTFLAGS $SHORTCUT_LANG_PARAM"
|
||||
CreateShortCut "$INSTDIR\$INSTSHORTCUT Portable.lnk" \
|
||||
"$INSTDIR\$INSTEXE" "$INSTFLAGS $SHORTCUT_LANG_PARAM --portable"
|
||||
CreateShortCut "$INSTDIR\Uninstall $INSTSHORTCUT.lnk" \
|
||||
'"$INSTDIR\uninst.exe"' ''
|
||||
|
||||
|
||||
@@ -1938,6 +1938,7 @@ void errorCallback(const std::string &error_string)
|
||||
}
|
||||
}
|
||||
|
||||
bool init_logging();
|
||||
bool LLAppViewer::initLogging()
|
||||
{
|
||||
//
|
||||
@@ -1947,6 +1948,10 @@ bool LLAppViewer::initLogging()
|
||||
gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
|
||||
LLError::setFatalFunction(errorCallback);
|
||||
|
||||
return init_logging();
|
||||
}
|
||||
bool init_logging()
|
||||
{
|
||||
// Remove the last ".old" log file.
|
||||
std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, OLD_LOG_FILE);
|
||||
LLFile::remove(old_log_file);
|
||||
@@ -2207,6 +2212,19 @@ bool LLAppViewer::initConfiguration()
|
||||
|
||||
// - selectively apply settings
|
||||
|
||||
// <singu> Portability Mode!
|
||||
if (clp.hasOption("portable"))
|
||||
{
|
||||
const std::string log = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LOG_FILE);
|
||||
llinfos << "Attempting to use portable settings and cache!" << llendl;
|
||||
gDirUtilp->makePortable();
|
||||
init_logging(); // Switch to portable log file
|
||||
llinfos << "Portable viewer configuration initialized!" << llendl;
|
||||
LLFile::remove(log);
|
||||
llinfos << "Cleaned up local log file to keep this computer untouched." << llendl;
|
||||
}
|
||||
// </singu>
|
||||
|
||||
// If the user has specified a alternate settings file name.
|
||||
// Load it now before loading the user_settings/settings.xml
|
||||
if(clp.hasOption("settings"))
|
||||
|
||||
Reference in New Issue
Block a user