summaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/pathutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/pathutil.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp
index 1ac76626..dc33e656 100644
--- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp
@@ -923,12 +923,14 @@ LExit:
923} 923}
924 924
925 925
926DAPI_(HRESULT) PathGetSystemTempPath( 926DAPI_(HRESULT) PathGetSystemTempPaths(
927 __out_z LPWSTR* psczSystemTempPath 927 __inout_z LPWSTR** prgsczSystemTempPaths,
928 __inout DWORD* pcSystemTempPaths
928 ) 929 )
929{ 930{
930 HRESULT hr = S_OK; 931 HRESULT hr = S_OK;
931 HKEY hKey = NULL; 932 HKEY hKey = NULL;
933 LPWSTR sczTemp = NULL;
932 WCHAR wzTempPath[MAX_PATH + 1] = { }; 934 WCHAR wzTempPath[MAX_PATH + 1] = { };
933 DWORD cch = 0; 935 DWORD cch = 0;
934 936
@@ -940,26 +942,36 @@ DAPI_(HRESULT) PathGetSystemTempPath(
940 942
941 // Follow documented precedence rules for TMP/TEMP from ::GetTempPath. 943 // Follow documented precedence rules for TMP/TEMP from ::GetTempPath.
942 // TODO: values will be expanded with the current environment variables instead of the system environment variables. 944 // TODO: values will be expanded with the current environment variables instead of the system environment variables.
943 hr = RegReadString(hKey, L"TMP", psczSystemTempPath); 945 hr = RegReadString(hKey, L"TMP", &sczTemp);
944 if (E_FILENOTFOUND != hr) 946 if (E_FILENOTFOUND != hr)
945 { 947 {
946 PathExitOnFailure(hr, "Failed to get system TMP value."); 948 PathExitOnFailure(hr, "Failed to get system TMP value.");
947 949
948 hr = PathBackslashTerminate(psczSystemTempPath); 950 hr = PathBackslashTerminate(&sczTemp);
949 PathExitOnFailure(hr, "Failed to backslash terminate system TMP value."); 951 PathExitOnFailure(hr, "Failed to backslash terminate system TMP value.");
950 952
951 ExitFunction(); 953 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 3);
954 PathExitOnFailure(hr, "Failed to ensure array size for system TMP value.");
955
956 (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp;
957 sczTemp = NULL;
958 *pcSystemTempPaths += 1;
952 } 959 }
953 960
954 hr = RegReadString(hKey, L"TEMP", psczSystemTempPath); 961 hr = RegReadString(hKey, L"TEMP", &sczTemp);
955 if (E_FILENOTFOUND != hr) 962 if (E_FILENOTFOUND != hr)
956 { 963 {
957 PathExitOnFailure(hr, "Failed to get system TEMP value."); 964 PathExitOnFailure(hr, "Failed to get system TEMP value.");
958 965
959 hr = PathBackslashTerminate(psczSystemTempPath); 966 hr = PathBackslashTerminate(&sczTemp);
960 PathExitOnFailure(hr, "Failed to backslash terminate system TEMP value."); 967 PathExitOnFailure(hr, "Failed to backslash terminate system TEMP value.");
961 968
962 ExitFunction(); 969 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 2);
970 PathExitOnFailure(hr, "Failed to ensure array size for system TEMP value.");
971
972 (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp;
973 sczTemp = NULL;
974 *pcSystemTempPaths += 1;
963 } 975 }
964 } 976 }
965 977
@@ -973,11 +985,19 @@ DAPI_(HRESULT) PathGetSystemTempPath(
973 PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long."); 985 PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long.");
974 } 986 }
975 987
976 hr = PathConcat(wzTempPath, L"TEMP\\", psczSystemTempPath); 988 hr = PathConcat(wzTempPath, L"TEMP\\", &sczTemp);
977 PathExitOnFailure(hr, "Failed to concat Temp directory on Windows directory path."); 989 PathExitOnFailure(hr, "Failed to concat Temp directory on Windows directory path.");
978 990
991 hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 1);
992 PathExitOnFailure(hr, "Failed to ensure array size for Windows\\TEMP value.");
993
994 (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp;
995 sczTemp = NULL;
996 *pcSystemTempPaths += 1;
997
979LExit: 998LExit:
980 ReleaseRegKey(hKey); 999 ReleaseRegKey(hKey);
1000 ReleaseStr(sczTemp);
981 1001
982 return hr; 1002 return hr;
983} 1003}