diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/path3utl.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/path3utl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/path3utl.cpp b/src/libs/dutil/WixToolset.DUtil/path3utl.cpp index cb6ce6d5..844cbfbb 100644 --- a/src/libs/dutil/WixToolset.DUtil/path3utl.cpp +++ b/src/libs/dutil/WixToolset.DUtil/path3utl.cpp | |||
@@ -17,6 +17,7 @@ | |||
17 | #define PathExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_PATHUTIL, p, x, s, __VA_ARGS__) | 17 | #define PathExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_PATHUTIL, p, x, s, __VA_ARGS__) |
18 | #define PathExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_PATHUTIL, e, x, s, __VA_ARGS__) | 18 | #define PathExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_PATHUTIL, e, x, s, __VA_ARGS__) |
19 | #define PathExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_PATHUTIL, g, x, s, __VA_ARGS__) | 19 | #define PathExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_PATHUTIL, g, x, s, __VA_ARGS__) |
20 | #define PathExitOnPathFailure(x, b, s, ...) ExitOnPathFailureSource(DUTIL_SOURCE_PATHUTIL, x, b, s, __VA_ARGS__) | ||
20 | 21 | ||
21 | static HRESULT GetTempPathFromSystemEnvironmentVariable( | 22 | static HRESULT GetTempPathFromSystemEnvironmentVariable( |
22 | __in HKEY hKey, | 23 | __in HKEY hKey, |
@@ -32,6 +33,7 @@ DAPI_(HRESULT) PathGetSystemTempPaths( | |||
32 | HRESULT hr = S_OK; | 33 | HRESULT hr = S_OK; |
33 | HMODULE hModule = NULL; | 34 | HMODULE hModule = NULL; |
34 | BOOL fSystem = FALSE; | 35 | BOOL fSystem = FALSE; |
36 | BOOL fExists = FALSE; | ||
35 | HKEY hKey = NULL; | 37 | HKEY hKey = NULL; |
36 | LPWSTR sczTemp = NULL; | 38 | LPWSTR sczTemp = NULL; |
37 | 39 | ||
@@ -61,10 +63,10 @@ DAPI_(HRESULT) PathGetSystemTempPaths( | |||
61 | 63 | ||
62 | // There is no documented API to get system environment variables, so read them from the registry. | 64 | // There is no documented API to get system environment variables, so read them from the registry. |
63 | hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_READ, &hKey); | 65 | hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_READ, &hKey); |
64 | if (E_FILENOTFOUND != hr) | 66 | PathExitOnPathFailure(hr, fExists, "Failed to open system environment registry key."); |
65 | { | ||
66 | PathExitOnFailure(hr, "Failed to open system environment registry key."); | ||
67 | 67 | ||
68 | if (fExists) | ||
69 | { | ||
68 | hr = GetTempPathFromSystemEnvironmentVariable(hKey, L"TMP", &sczTemp); | 70 | hr = GetTempPathFromSystemEnvironmentVariable(hKey, L"TMP", &sczTemp); |
69 | PathExitOnFailure(hr, "Failed to get temp path from system TMP."); | 71 | PathExitOnFailure(hr, "Failed to get temp path from system TMP."); |
70 | 72 | ||
@@ -118,14 +120,16 @@ static HRESULT GetTempPathFromSystemEnvironmentVariable( | |||
118 | HRESULT hr = S_OK; | 120 | HRESULT hr = S_OK; |
119 | LPWSTR sczValue = NULL; | 121 | LPWSTR sczValue = NULL; |
120 | BOOL fNeedsExpansion = FALSE; | 122 | BOOL fNeedsExpansion = FALSE; |
123 | BOOL fExists = FALSE; | ||
121 | 124 | ||
122 | // Read the value unexpanded so that it can be expanded with system environment variables. | 125 | // Read the value unexpanded so that it can be expanded with system environment variables. |
123 | hr = RegReadUnexpandedString(hKey, wzName, &fNeedsExpansion, &sczValue); | 126 | hr = RegReadUnexpandedString(hKey, wzName, &fNeedsExpansion, &sczValue); |
124 | if (E_FILENOTFOUND == hr) | 127 | PathExitOnPathFailure(hr, fExists, "Failed to get system '%ls' value.", wzName); |
128 | |||
129 | if (!fExists) | ||
125 | { | 130 | { |
126 | ExitFunction1(hr = S_FALSE); | 131 | ExitFunction1(hr = S_FALSE); |
127 | } | 132 | } |
128 | PathExitOnFailure(hr, "Failed to get system '%ls' value.", wzName); | ||
129 | 133 | ||
130 | if (fNeedsExpansion) | 134 | if (fNeedsExpansion) |
131 | { | 135 | { |