summaryrefslogtreecommitdiff
path: root/indra/llvfs/lldir_win32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llvfs/lldir_win32.cpp')
-rw-r--r--indra/llvfs/lldir_win32.cpp126
1 files changed, 85 insertions, 41 deletions
diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp
index f415fe56ed..52d864e26f 100644
--- a/indra/llvfs/lldir_win32.cpp
+++ b/indra/llvfs/lldir_win32.cpp
@@ -2,30 +2,25 @@
* @file lldir_win32.cpp
* @brief Implementation of directory utilities for windows
*
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -58,14 +53,18 @@ LLDir_Win32::LLDir_Win32()
mOSUserDir = utf16str_to_utf8str(llutf16string(w_str));
- // Local Settings\Application Data is where cache files should
- // go, they don't get copied to the server if the user moves his
- // profile around on the network. JC
+ // We want cache files to go on the local disk, even if the
+ // user is on a network with a "roaming profile".
+ //
+ // On XP this is:
+ // C:\Docments and Settings\James\Local Settings\Application Data
+ // On Vista this is:
+ // C:\Users\James\AppData\Local
//
- // TODO: patch the installer to remove old cache files on update, then
- // enable this code.
- //SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE);
- //mOSUserCacheDir = utf16str_to_utf8str(llutf16string(w_str));
+ // We used to store the cache in AppData\Roaming, and the installer
+ // cleans up that version on upgrade. JC
+ SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE);
+ mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str));
if (GetTempPath(MAX_PATH, w_str))
{
@@ -116,10 +115,36 @@ LLDir_Win32::LLDir_Win32()
GetCurrentDirectory(MAX_PATH, w_str);
mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
#endif
- if (strstr(mExecutableDir.c_str(), "indra\\newview"))
- mAppRODataDir = getCurPath();
- else
- mAppRODataDir = mExecutableDir;
+
+ if (mExecutableDir.find("indra") == std::string::npos)
+ {
+ // Running from installed directory. Make sure current
+ // directory isn't something crazy (e.g. if invoking from
+ // command line).
+ SetCurrentDirectory(utf8str_to_utf16str(mExecutableDir).c_str());
+ GetCurrentDirectory(MAX_PATH, w_str);
+ mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
+ }
+ mAppRODataDir = mWorkingDir;
+
+ llinfos << "mAppRODataDir = " << mAppRODataDir << llendl;
+
+ mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins";
+
+ // Build the default cache directory
+ mDefaultCacheDir = buildSLOSCacheDir();
+
+ // Make sure it exists
+ int res = LLFile::mkdir(mDefaultCacheDir);
+ if (res == -1)
+ {
+ if (errno != EEXIST)
+ {
+ llwarns << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << llendl;
+ }
+ }
+
+ mLLPluginDir = mExecutableDir + mDirDelimiter + "llplugin";
}
LLDir_Win32::~LLDir_Win32()
@@ -128,14 +153,21 @@ LLDir_Win32::~LLDir_Win32()
// Implementation
-void LLDir_Win32::initAppDirs(const std::string &app_name)
+void LLDir_Win32::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;
mOSUserAppDir = mOSUserDir;
mOSUserAppDir += "\\";
mOSUserAppDir += app_name;
- int res = LLFile::mkdir(mOSUserAppDir.c_str());
+ int res = LLFile::mkdir(mOSUserAppDir);
if (res == -1)
{
if (errno != EEXIST)
@@ -147,7 +179,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name)
}
//dumpCurrentDirectories();
- res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,"").c_str());
+ res = LLFile::mkdir(getExpandedFilename(LL_PATH_LOGS,""));
if (res == -1)
{
if (errno != EEXIST)
@@ -156,7 +188,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name)
}
}
- res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,"").c_str());
+ res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SETTINGS,""));
if (res == -1)
{
if (errno != EEXIST)
@@ -165,7 +197,7 @@ void LLDir_Win32::initAppDirs(const std::string &app_name)
}
}
- res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,"").c_str());
+ res = LLFile::mkdir(getExpandedFilename(LL_PATH_CACHE,""));
if (res == -1)
{
if (errno != EEXIST)
@@ -174,15 +206,14 @@ void LLDir_Win32::initAppDirs(const std::string &app_name)
}
}
- res = LLFile::mkdir(getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"").c_str());
+ res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SKIN,""));
if (res == -1)
{
if (errno != EEXIST)
{
- llwarns << "Couldn't create LL_PATH_MOZILLA_PROFILE dir " << getExpandedFilename(LL_PATH_MOZILLA_PROFILE,"") << llendl;
+ llwarns << "Couldn't create LL_PATH_SKINS dir " << getExpandedFilename(LL_PATH_USER_SKIN,"") << llendl;
}
}
-
mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem");
}
@@ -338,12 +369,12 @@ std::string LLDir_Win32::getCurPath()
}
-BOOL LLDir_Win32::fileExists(const std::string &filename)
+BOOL LLDir_Win32::fileExists(const std::string &filename) const
{
llstat stat_data;
// Check the age of the file
// Now, we see if the files we've gathered are recent...
- int res = LLFile::stat(filename.c_str(), &stat_data);
+ int res = LLFile::stat(filename, &stat_data);
if (!res)
{
return TRUE;
@@ -355,6 +386,19 @@ BOOL LLDir_Win32::fileExists(const std::string &filename)
}
+/*virtual*/ std::string LLDir_Win32::getLLPluginLauncher()
+{
+ return gDirUtilp->getExecutableDir() + gDirUtilp->getDirDelimiter() +
+ "SLPlugin.exe";
+}
+
+/*virtual*/ std::string LLDir_Win32::getLLPluginFilename(std::string base_name)
+{
+ return gDirUtilp->getLLPluginDir() + gDirUtilp->getDirDelimiter() +
+ base_name + ".dll";
+}
+
+
#if 0
// Utility function to get version number of a DLL