aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-08-03 15:41:02 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-08-04 10:03:57 -0500
commited57d171f6fb6bb4e180696cc12caa568599566a (patch)
treec1e6cbe61440d44f3f11160512e12042ce7ddd2a /src/burn
parent5815688519a60e63e18c13dfe0908d76757cbc53 (diff)
downloadwix-ed57d171f6fb6bb4e180696cc12caa568599566a.tar.gz
wix-ed57d171f6fb6bb4e180696cc12caa568599566a.tar.bz2
wix-ed57d171f6fb6bb4e180696cc12caa568599566a.zip
Get system TEMP path from the registry.
Also, correctly handle return codes from related path APIs.
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/cache.cpp23
-rw-r--r--src/burn/engine/variable.cpp1
2 files changed, 9 insertions, 15 deletions
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp
index 61416aed..a35b83bc 100644
--- a/src/burn/engine/cache.cpp
+++ b/src/burn/engine/cache.cpp
@@ -1281,7 +1281,7 @@ static HRESULT CalculateWorkingFolder(
1281 HRESULT hr = S_OK; 1281 HRESULT hr = S_OK;
1282 RPC_STATUS rs = RPC_S_OK; 1282 RPC_STATUS rs = RPC_S_OK;
1283 BOOL fElevated = FALSE; 1283 BOOL fElevated = FALSE;
1284 WCHAR wzTempPath[MAX_PATH] = { }; 1284 LPWSTR sczTempPath = NULL;
1285 UUID guid = {}; 1285 UUID guid = {};
1286 WCHAR wzGuid[39]; 1286 WCHAR wzGuid[39];
1287 1287
@@ -1291,20 +1291,13 @@ static HRESULT CalculateWorkingFolder(
1291 1291
1292 if (fElevated) 1292 if (fElevated)
1293 { 1293 {
1294 if (!::GetWindowsDirectoryW(wzTempPath, countof(wzTempPath))) 1294 hr = PathGetSystemTempPath(&sczTempPath);
1295 { 1295 ExitOnFailure(hr, "Failed to get system temp folder path for working folder.");
1296 ExitWithLastError(hr, "Failed to get windows path for working folder.");
1297 }
1298
1299 hr = PathFixedBackslashTerminate(wzTempPath, countof(wzTempPath));
1300 ExitOnFailure(hr, "Failed to ensure windows path for working folder ended in backslash.");
1301
1302 hr = ::StringCchCatW(wzTempPath, countof(wzTempPath), L"Temp\\");
1303 ExitOnFailure(hr, "Failed to concat Temp directory on windows path for working folder.");
1304 } 1296 }
1305 else if (0 == ::GetTempPathW(countof(wzTempPath), wzTempPath)) 1297 else
1306 { 1298 {
1307 ExitWithLastError(hr, "Failed to get temp path for working folder."); 1299 hr = PathGetTempPath(&sczTempPath);
1300 ExitOnFailure(hr, "Failed to get temp folder path for working folder.");
1308 } 1301 }
1309 1302
1310 rs = ::UuidCreate(&guid); 1303 rs = ::UuidCreate(&guid);
@@ -1317,7 +1310,7 @@ static HRESULT CalculateWorkingFolder(
1317 ExitOnRootFailure(hr, "Failed to convert working folder guid into string."); 1310 ExitOnRootFailure(hr, "Failed to convert working folder guid into string.");
1318 } 1311 }
1319 1312
1320 hr = StrAllocFormatted(&vsczWorkingFolder, L"%ls%ls\\", wzTempPath, wzGuid); 1313 hr = StrAllocFormatted(&vsczWorkingFolder, L"%ls%ls\\", sczTempPath, wzGuid);
1321 ExitOnFailure(hr, "Failed to append bundle id on to temp path for working folder."); 1314 ExitOnFailure(hr, "Failed to append bundle id on to temp path for working folder.");
1322 } 1315 }
1323 1316
@@ -1325,6 +1318,8 @@ static HRESULT CalculateWorkingFolder(
1325 ExitOnFailure(hr, "Failed to copy working folder path."); 1318 ExitOnFailure(hr, "Failed to copy working folder path.");
1326 1319
1327LExit: 1320LExit:
1321 ReleaseStr(sczTempPath);
1322
1328 return hr; 1323 return hr;
1329} 1324}
1330 1325
diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp
index e2b1f1f2..e7391a9f 100644
--- a/src/burn/engine/variable.cpp
+++ b/src/burn/engine/variable.cpp
@@ -1916,7 +1916,6 @@ static HRESULT InitializeVariableTempFolder(
1916 HRESULT hr = S_OK; 1916 HRESULT hr = S_OK;
1917 WCHAR wzPath[MAX_PATH] = { }; 1917 WCHAR wzPath[MAX_PATH] = { };
1918 1918
1919 // get volume path name
1920 if (!::GetTempPathW(MAX_PATH, wzPath)) 1919 if (!::GetTempPathW(MAX_PATH, wzPath))
1921 { 1920 {
1922 ExitWithLastError(hr, "Failed to get temp path."); 1921 ExitWithLastError(hr, "Failed to get temp path.");