diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp index becfc67e..0e2a5dec 100644 --- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp | |||
@@ -894,86 +894,6 @@ LExit: | |||
894 | } | 894 | } |
895 | 895 | ||
896 | 896 | ||
897 | DAPI_(HRESULT) PathGetSystemTempPaths( | ||
898 | __inout_z LPWSTR** prgsczSystemTempPaths, | ||
899 | __inout DWORD* pcSystemTempPaths | ||
900 | ) | ||
901 | { | ||
902 | HRESULT hr = S_OK; | ||
903 | HKEY hKey = NULL; | ||
904 | LPWSTR sczTemp = NULL; | ||
905 | WCHAR wzTempPath[MAX_PATH + 1] = { }; | ||
906 | DWORD cch = 0; | ||
907 | |||
908 | // There is no documented API to get system environment variables, so read them from the registry. | ||
909 | hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_READ, &hKey); | ||
910 | if (E_FILENOTFOUND != hr) | ||
911 | { | ||
912 | PathExitOnFailure(hr, "Failed to open system environment registry key."); | ||
913 | |||
914 | // Follow documented precedence rules for TMP/TEMP from ::GetTempPath. | ||
915 | // TODO: values will be expanded with the current environment variables instead of the system environment variables. | ||
916 | hr = RegReadString(hKey, L"TMP", &sczTemp); | ||
917 | if (E_FILENOTFOUND != hr) | ||
918 | { | ||
919 | PathExitOnFailure(hr, "Failed to get system TMP value."); | ||
920 | |||
921 | hr = PathBackslashTerminate(&sczTemp); | ||
922 | PathExitOnFailure(hr, "Failed to backslash terminate system TMP value."); | ||
923 | |||
924 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 3); | ||
925 | PathExitOnFailure(hr, "Failed to ensure array size for system TMP value."); | ||
926 | |||
927 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
928 | sczTemp = NULL; | ||
929 | *pcSystemTempPaths += 1; | ||
930 | } | ||
931 | |||
932 | hr = RegReadString(hKey, L"TEMP", &sczTemp); | ||
933 | if (E_FILENOTFOUND != hr) | ||
934 | { | ||
935 | PathExitOnFailure(hr, "Failed to get system TEMP value."); | ||
936 | |||
937 | hr = PathBackslashTerminate(&sczTemp); | ||
938 | PathExitOnFailure(hr, "Failed to backslash terminate system TEMP value."); | ||
939 | |||
940 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 2); | ||
941 | PathExitOnFailure(hr, "Failed to ensure array size for system TEMP value."); | ||
942 | |||
943 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
944 | sczTemp = NULL; | ||
945 | *pcSystemTempPaths += 1; | ||
946 | } | ||
947 | } | ||
948 | |||
949 | cch = ::GetSystemWindowsDirectoryW(wzTempPath, countof(wzTempPath)); | ||
950 | if (!cch) | ||
951 | { | ||
952 | PathExitWithLastError(hr, "Failed to get Windows directory path."); | ||
953 | } | ||
954 | else if (cch >= countof(wzTempPath)) | ||
955 | { | ||
956 | PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long."); | ||
957 | } | ||
958 | |||
959 | hr = PathConcat(wzTempPath, L"TEMP\\", &sczTemp); | ||
960 | PathExitOnFailure(hr, "Failed to concat Temp directory on Windows directory path."); | ||
961 | |||
962 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 1); | ||
963 | PathExitOnFailure(hr, "Failed to ensure array size for Windows\\TEMP value."); | ||
964 | |||
965 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
966 | sczTemp = NULL; | ||
967 | *pcSystemTempPaths += 1; | ||
968 | |||
969 | LExit: | ||
970 | ReleaseRegKey(hKey); | ||
971 | ReleaseStr(sczTemp); | ||
972 | |||
973 | return hr; | ||
974 | } | ||
975 | |||
976 | |||
977 | DAPI_(HRESULT) PathGetKnownFolder( | 897 | DAPI_(HRESULT) PathGetKnownFolder( |
978 | __in int csidl, | 898 | __in int csidl, |
979 | __out LPWSTR* psczKnownFolder | 899 | __out LPWSTR* psczKnownFolder |