From e46fc0a805ea50d2c3ee5fa6b0f2b00a1335a2a2 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Mon, 9 Jun 2014 00:00:43 -0400 Subject: [PATCH] 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 --- indra/llvfs/lldir.cpp | 27 +++++++++++++++++++ indra/llvfs/lldir.h | 1 + indra/newview/app_settings/cmd_line.xml | 6 +++++ .../installers/windows/installer_template.nsi | 2 ++ indra/newview/llappviewer.cpp | 18 +++++++++++++ 5 files changed, 54 insertions(+) diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index c3a042247..e0d85a477 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -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() ) diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 5058b5479..2be6dd3ec 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -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 diff --git a/indra/newview/app_settings/cmd_line.xml b/indra/newview/app_settings/cmd_line.xml index 7e35949ed..253b0ad6e 100644 --- a/indra/newview/app_settings/cmd_line.xml +++ b/indra/newview/app_settings/cmd_line.xml @@ -253,6 +253,12 @@ UserConnectionPort + portable + + count + 0 + + purge desc diff --git a/indra/newview/installers/windows/installer_template.nsi b/indra/newview/installers/windows/installer_template.nsi index 3f2cfbd0f..1f3c8be57 100644 --- a/indra/newview/installers/windows/installer_template.nsi +++ b/indra/newview/installers/windows/installer_template.nsi @@ -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"' '' diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 98f056c24..754eb4501 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -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 + // 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; + } + // + // If the user has specified a alternate settings file name. // Load it now before loading the user_settings/settings.xml if(clp.hasOption("settings"))