From 83e0ee0f3fa57ba0eb3cd69b334aec6554c1fdf6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 14 Sep 2010 20:10:44 -0700 Subject: fixed full path not appearing in debug output for param block errors by using full path for LLDir::mAppRODataDir --- indra/llvfs/lldir_win32.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llvfs/lldir_win32.cpp') diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index 8b1a2ddd3c..52d864e26f 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -116,10 +116,6 @@ LLDir_Win32::LLDir_Win32() mExecutableDir = utf16str_to_utf8str(llutf16string(w_str)); #endif - mAppRODataDir = "."; - - mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; - if (mExecutableDir.find("indra") == std::string::npos) { // Running from installed directory. Make sure current @@ -129,8 +125,12 @@ LLDir_Win32::LLDir_Win32() 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(); -- cgit v1.2.3 From 4fa6500b5107f9d300a6ab7b6f011fb19621b05c Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 28 Oct 2010 18:09:09 -0400 Subject: STORM-480 remove unused "wrap" parameter from LLDir::getNetFileInDir --HG-- branch : storm-102 --- indra/llvfs/lldir_win32.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'indra/llvfs/lldir_win32.cpp') diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index 52d864e26f..ecfa4a07d4 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -247,14 +247,14 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string & // 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) +BOOL LLDir_Win32::getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) { llutf16string dirnamew = utf8str_to_utf16str(dirname); - return getNextFileInDir(dirnamew, mask, fname, wrap); + return getNextFileInDir(dirnamew, mask, fname); } -BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname, BOOL wrap) +BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname) { WIN32_FIND_DATAW FileData; @@ -290,15 +290,8 @@ BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::stri FindClose(mDirSearch_h); mCurrentDir[0] = NULL; - if (wrap) - { - return(getNextFileInDir(pathname,"",fname,TRUE)); - } - else - { - fname[0] = 0; - return(FALSE); - } + fname[0] = 0; + return(FALSE); } else { @@ -318,7 +311,6 @@ BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::stri // 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; -- cgit v1.2.3 From 330978decd15e02d7cd23dcead52dc2373d7e5d5 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 28 Oct 2010 22:40:37 -0400 Subject: STORM-480 remove (unused) LLDir::getRandomFileInDir --HG-- branch : storm-102 --- indra/llvfs/lldir_win32.cpp | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'indra/llvfs/lldir_win32.cpp') diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index ecfa4a07d4..a721552999 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -310,47 +310,6 @@ BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::stri } -// get a random file in the directory -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() { -- cgit v1.2.3 From 96112dfa2628569dea42bcf968eb7566d97e85f7 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 3 Nov 2010 13:33:29 -0400 Subject: STORM-477: fixed getNextFileInDir on Windows7, improved test cases and documentation --HG-- branch : storm-102 --- indra/llvfs/lldir_win32.cpp | 80 +++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 43 deletions(-) (limited to 'indra/llvfs/lldir_win32.cpp') diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index a721552999..4a8526cc96 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -246,21 +246,13 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string & // 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) { - llutf16string dirnamew = utf8str_to_utf16str(dirname); - return getNextFileInDir(dirnamew, mask, fname); - -} + BOOL fileFound = FALSE; + fname = ""; -BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::string &mask, std::string &fname) -{ WIN32_FIND_DATAW FileData; - - fname = ""; - llutf16string pathname = dirname; - pathname += utf8str_to_utf16str(mask); + llutf16string pathname = utf8str_to_utf16str(dirname) + utf8str_to_utf16str(mask); if (pathname != mCurrentDir) { @@ -273,43 +265,45 @@ BOOL LLDir_Win32::getNextFileInDir(const llutf16string &dirname, const std::stri // 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 ((mDirSearch_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_NO_MORE_FILES) - { - // No more files, so reset to beginning of directory - FindClose(mDirSearch_h); - mCurrentDir[0] = NULL; - - fname[0] = 0; - return(FALSE); - } - else - { - // Error -// llinfos << "Unable to locate next file" << llendl; - return(FALSE); - } + fileFound = TRUE; } } - // convert from TCHAR to char - fname = utf16str_to_utf8str(FileData.cFileName); - - // fname now first name in list - return(TRUE); -} - + // Loop to skip over the current (.) and parent (..) directory entries + // (apparently returned in Win7 but not XP) + do + { + if ( fileFound + && ( (lstrcmp(FileData.cFileName, (LPCTSTR)TEXT(".")) == 0) + ||(lstrcmp(FileData.cFileName, (LPCTSTR)TEXT("..")) == 0) + ) + ) + { + fileFound = FALSE; + } + } while ( mDirSearch_h != INVALID_HANDLE_VALUE + && !fileFound + && (fileFound = FindNextFile(mDirSearch_h, &FileData) + ) + ); + + if (!fileFound && GetLastError() == ERROR_NO_MORE_FILES) + { + // No more files, so reset to beginning of directory + FindClose(mDirSearch_h); + mCurrentDir[0] = '\000'; + } + if (fileFound) + { + // convert from TCHAR to char + fname = utf16str_to_utf8str(FileData.cFileName); + } + + return fileFound; +} std::string LLDir_Win32::getCurPath() { -- cgit v1.2.3