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.cpp166
1 files changed, 23 insertions, 143 deletions
diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp
index 52d864e26f..7709945123 100644
--- a/indra/llvfs/lldir_win32.cpp
+++ b/indra/llvfs/lldir_win32.cpp
@@ -81,10 +81,11 @@ LLDir_Win32::LLDir_Win32()
// fprintf(stderr, "mTempDir = <%s>",mTempDir);
-#if 1
- // Don't use the real app path for now, as we'll have to add parsing to detect if
- // we're in a developer tree, which has a different structure from the installed product.
+ // Set working directory, for LLDir::getWorkingDir()
+ GetCurrentDirectory(MAX_PATH, w_str);
+ mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
+ // Set the executable directory
S32 size = GetModuleFileName(NULL, w_str, MAX_PATH);
if (size)
{
@@ -100,32 +101,35 @@ LLDir_Win32::LLDir_Win32()
{
mExecutableFilename = mExecutablePathAndName;
}
- GetCurrentDirectory(MAX_PATH, w_str);
- mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
}
else
{
fprintf(stderr, "Couldn't get APP path, assuming current directory!");
- GetCurrentDirectory(MAX_PATH, w_str);
- mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
+ mExecutableDir = mWorkingDir;
// Assume it's the current directory
}
-#else
- GetCurrentDirectory(MAX_PATH, w_str);
- mExecutableDir = utf16str_to_utf8str(llutf16string(w_str));
-#endif
- if (mExecutableDir.find("indra") == std::string::npos)
+ // mAppRODataDir = ".";
+
+ // Determine the location of the App-Read-Only-Data
+ // Try the working directory then the exe's dir.
+ mAppRODataDir = mWorkingDir;
+
+
+// if (mExecutableDir.find("indra") == std::string::npos)
+
+ // *NOTE:Mani - It is a mistake to put viewer specific code in
+ // the LLDir implementation. The references to 'skins' and
+ // 'llplugin' need to go somewhere else.
+ // alas... this also gets called during static initialization
+ // time due to the construction of gDirUtil in lldir.cpp.
+ if(! LLFile::isdir(mAppRODataDir + mDirDelimiter + "skins"))
{
- // 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));
+ // What? No skins in the working dir?
+ // Try the executable's directory.
+ mAppRODataDir = mExecutableDir;
}
- mAppRODataDir = mWorkingDir;
llinfos << "mAppRODataDir = " << mAppRODataDir << llendl;
@@ -206,14 +210,6 @@ void LLDir_Win32::initAppDirs(const std::string &app_name,
}
}
- res = LLFile::mkdir(getExpandedFilename(LL_PATH_USER_SKIN,""));
- if (res == -1)
- {
- if (errno != EEXIST)
- {
- llwarns << "Couldn't create LL_PATH_SKINS dir " << getExpandedFilename(LL_PATH_USER_SKIN,"") << llendl;
- }
- }
mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem");
}
@@ -244,122 +240,6 @@ U32 LLDir_Win32::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_Win32::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap)
-{
- llutf16string dirnamew = utf8str_to_utf16str(dirname);
- return getNextFileInDir(dirnamew, mask, fname, wrap);
-
-}
-
-BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname, BOOL wrap)
-{
- WIN32_FIND_DATAW FileData;
-
- fname = "";
- llutf16string pathname = dirname;
- pathname += utf8str_to_utf16str(mask);
-
- if (pathname != mCurrentDir)
- {
- // different dir specified, close old search
- if (mCurrentDir[0])
- {
- FindClose(mDirSearch_h);
- }
- mCurrentDir = pathname;
-
- // and open new one
- // Check error opening Directory structure
- if ((mDirSearch_h = FindFirstFile(pathname.c_str(), &FileData)) == INVALID_HANDLE_VALUE)
- {
-// llinfos << "Unable to locate first file" << llendl;
- return(FALSE);
- }
- }
- else // get next file in list
- {
- // Find next entry
- if (!FindNextFile(mDirSearch_h, &FileData))
- {
- if (GetLastError() == ERROR_NO_MORE_FILES)
- {
- // No more files, so reset to beginning of directory
- FindClose(mDirSearch_h);
- mCurrentDir[0] = NULL;
-
- if (wrap)
- {
- return(getNextFileInDir(pathname,"",fname,TRUE));
- }
- else
- {
- fname[0] = 0;
- return(FALSE);
- }
- }
- else
- {
- // Error
-// llinfos << "Unable to locate next file" << llendl;
- return(FALSE);
- }
- }
- }
-
- // convert from TCHAR to char
- fname = utf16str_to_utf8str(FileData.cFileName);
-
- // fname now first name in list
- return(TRUE);
-}
-
-
-// get a random file in the directory
-// automatically wrap if we've hit the end
-void LLDir_Win32::getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname)
-{
- S32 num_files;
- S32 which_file;
- HANDLE random_search_h;
-
- fname = "";
-
- llutf16string pathname = utf8str_to_utf16str(dirname);
- pathname += utf8str_to_utf16str(mask);
-
- WIN32_FIND_DATA FileData;
- fname[0] = NULL;
-
- num_files = countFilesInDir(dirname,mask);
- if (!num_files)
- {
- return;
- }
-
- which_file = ll_rand(num_files);
-
-// llinfos << "Random select mp3 #" << which_file << llendl;
-
- // which_file now indicates the (zero-based) index to which file to play
-
- if ((random_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
- {
- while (which_file--)
- {
- if (!FindNextFile(random_search_h, &FileData))
- {
- return;
- }
- }
- FindClose(random_search_h);
-
- fname = utf16str_to_utf8str(llutf16string(FileData.cFileName));
- }
-}
-
std::string LLDir_Win32::getCurPath()
{
WCHAR w_str[MAX_PATH];