diff options
author | callum_linden <callum@lindenlab.com> | 2017-12-18 17:14:28 -0800 |
---|---|---|
committer | callum_linden <callum@lindenlab.com> | 2017-12-18 17:14:28 -0800 |
commit | b2bbd91669690c22ded28a5890153bb780b7dc62 (patch) | |
tree | 48a1295cf87c4699f98754d42ca29dd1c2267aa3 | |
parent | 6ced87c0275ec20fca994f8d2f61947d5ac62082 (diff) | |
parent | 34a9de7270efc4aa45504eb70ec7367cf7162603 (diff) |
Automated merge with head of lindenlab/viewer64
-rw-r--r-- | autobuild.xml | 10 | ||||
-rw-r--r-- | indra/llvfs/lldir_win32.cpp | 63 | ||||
-rw-r--r-- | indra/test/CMakeLists.txt | 4 |
3 files changed, 62 insertions, 15 deletions
diff --git a/autobuild.xml b/autobuild.xml index 22480d67a0..9b8bd6018a 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3231,9 +3231,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>archive</key> <map> <key>hash</key> - <string>8bb2754bb078713f875e7374c95294fc</string> + <string>a1cc313f9238316a514b8d3056f86b31</string> <key>url</key> - <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/11619/66949/viewer_manager-1.0.511355-darwin64-511355.tar.bz2</string> + <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/11774/68078/viewer_manager-1.0.511462-darwin64-511462.tar.bz2</string> </map> <key>name</key> <string>darwin64</string> @@ -3255,9 +3255,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>archive</key> <map> <key>hash</key> - <string>cc406ba4d9250e4c959c99b64877248f</string> + <string>73894a49bd63e06adc0e365efae6e03e</string> <key>url</key> - <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/11620/66955/viewer_manager-1.0.511355-windows-511355.tar.bz2</string> + <string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/11775/68084/viewer_manager-1.0.511462-windows-511462.tar.bz2</string> </map> <key>name</key> <string>windows</string> @@ -3268,7 +3268,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>source_type</key> <string>hg</string> <key>version</key> - <string>1.0.511355</string> + <string>1.0.511462</string> </map> <key>vlc-bin</key> <map> diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index ebc8fdca33..4d8aa0e189 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -31,7 +31,11 @@ #include "lldir_win32.h" #include "llerror.h" #include "llrand.h" // for gLindenLabRandomNumber -#include "shlobj.h" +#include <shlobj.h> +#include <Knownfolders.h> +#include <iostream> +#include <map> +#include <Objbase.h> // CoTaskMemFree() #include <direct.h> #include <errno.h> @@ -42,30 +46,59 @@ #define PACKVERSION(major,minor) MAKELONG(minor,major) DWORD GetDllVersion(LPCTSTR lpszDllName); +namespace { + +std::string getKnownFolderPath(const std::string& desc, REFKNOWNFOLDERID folderid) +{ + // https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188(v=vs.85).aspx + PWSTR wstrptr = 0; + HRESULT result = SHGetKnownFolderPath( + folderid, + KF_FLAG_DEFAULT, // no flags + NULL, // current user, no impersonation + &wstrptr); + if (result == S_OK) + { + std::string utf8 = utf16str_to_utf8str(llutf16string(wstrptr)); + // have to free the returned pointer after copying its data + CoTaskMemFree(wstrptr); + return utf8; + } + + // gack, no logging yet! + // at least say something to a developer trying to debug this... + static std::map<HRESULT, const char*> codes + { + { E_FAIL, "E_FAIL; known folder does not have a path?" }, + { E_INVALIDARG, "E_INVALIDARG; not present on system?" } + }; + auto found = codes.find(result); + const char* text = (found == codes.end())? "unknown" : found->second; + std::cout << "*** SHGetKnownFolderPath(" << desc << ") failed with " + << result << " (" << text << ")\n"; + return {}; +} + +} // anonymous namespace + LLDir_Win32::LLDir_Win32() { mDirDelimiter = "\\"; - WCHAR w_str[MAX_PATH]; - // Application Data is where user settings go - SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE); - - mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); + mOSUserDir = getKnownFolderPath("RoamingAppData", FOLDERID_RoamingAppData); // 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 // // 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)); + mOSCacheDir = getKnownFolderPath("LocalAppData", FOLDERID_LocalAppData); + WCHAR w_str[MAX_PATH]; if (GetTempPath(MAX_PATH, w_str)) { if (wcslen(w_str)) /* Flawfinder: ignore */ @@ -73,6 +106,16 @@ LLDir_Win32::LLDir_Win32() w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } mTempDir = utf16str_to_utf8str(llutf16string(w_str)); + + if (mOSUserDir.empty()) + { + mOSUserDir = mTempDir; + } + + if (mOSCacheDir.empty()) + { + mOSCacheDir = mTempDir; + } } else { diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index 8344cead57..3f12431acc 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -73,6 +73,9 @@ if (NOT WINDOWS) list(APPEND test_SOURCE_FILES llmessagetemplateparser_tut.cpp ) + set(EXTRA_WINDOWS_LIBRARIES "") +else (NOT WINDOWS) + set(EXTRA_WINDOWS_LIBRARIES ole32) endif (NOT WINDOWS) set_source_files_properties(${test_HEADER_FILES} @@ -96,6 +99,7 @@ target_link_libraries(lltest ${GOOGLEMOCK_LIBRARIES} ${PTHREAD_LIBRARY} ${WINDOWS_LIBRARIES} + ${EXTRA_WINDOWS_LIBRARIES} ${BOOST_PROGRAM_OPTIONS_LIBRARY} ${BOOST_REGEX_LIBRARY} ${BOOST_COROUTINE_LIBRARY} |