summaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/path2utl.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/path2utl.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
index 9e48f9d5..c6ff608c 100644
--- a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp
@@ -246,3 +246,41 @@ LExit:
246 ReleaseStr(sczCanonicalizedDirectory); 246 ReleaseStr(sczCanonicalizedDirectory);
247 return hr; 247 return hr;
248} 248}
249
250
251DAPI_(HRESULT) PathSystemWindowsSubdirectory(
252 __in_z_opt LPCWSTR wzSubdirectory,
253 __out_z LPWSTR* psczFullPath
254 )
255{
256 HRESULT hr = S_OK;
257 WCHAR wzTempPath[MAX_PATH + 1] = { };
258 DWORD cch = 0;
259
260 cch = ::GetSystemWindowsDirectoryW(wzTempPath, countof(wzTempPath));
261 if (!cch)
262 {
263 PathExitWithLastError(hr, "Failed to get Windows directory path.");
264 }
265 else if (cch >= countof(wzTempPath))
266 {
267 PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long.");
268 }
269
270 if (wzSubdirectory)
271 {
272 hr = PathConcatRelativeToBase(wzTempPath, wzSubdirectory, psczFullPath);
273 PathExitOnFailure(hr, "Failed to concat subdirectory on Windows directory path.");
274 }
275 else
276 {
277 hr = StrAllocString(psczFullPath, wzTempPath, 0);
278 PathExitOnFailure(hr, "Failed to copy Windows directory path.");
279 }
280
281 hr = PathBackslashTerminate(psczFullPath);
282 PathExitOnFailure(hr, "Failed to terminate Windows directory path with backslash.");
283
284LExit:
285 return hr;
286}