diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/dirutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/dirutil.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/dirutil.cpp b/src/libs/dutil/WixToolset.DUtil/dirutil.cpp index c106a467..94eab9e7 100644 --- a/src/libs/dutil/WixToolset.DUtil/dirutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/dirutil.cpp | |||
@@ -364,17 +364,27 @@ extern "C" DWORD DAPI DirDeleteEmptyDirectoriesToRoot( | |||
364 | __in DWORD /*dwFlags*/ | 364 | __in DWORD /*dwFlags*/ |
365 | ) | 365 | ) |
366 | { | 366 | { |
367 | HRESULT hr = S_OK; | ||
367 | DWORD cDeletedDirs = 0; | 368 | DWORD cDeletedDirs = 0; |
368 | LPWSTR sczPath = NULL; | 369 | LPWSTR sczPath = NULL; |
370 | LPCWSTR wzPastRoot = NULL; | ||
371 | SIZE_T cchRoot = 0; | ||
372 | |||
373 | // Make sure the path is normalized and prefixed. | ||
374 | hr = PathExpand(&sczPath, wzPath, PATH_EXPAND_FULLPATH); | ||
375 | DirExitOnFailure(hr, "Failed to get full path for: %ls", wzPath); | ||
376 | |||
377 | wzPastRoot = PathSkipPastRoot(sczPath, NULL, NULL, NULL); | ||
378 | DirExitOnNull(wzPastRoot, hr, E_INVALIDARG, "Full path was not rooted: %ls", sczPath); | ||
369 | 379 | ||
370 | while (wzPath && *wzPath && ::RemoveDirectoryW(wzPath)) | 380 | cchRoot = wzPastRoot - sczPath; |
381 | |||
382 | while (sczPath && sczPath[cchRoot] && ::RemoveDirectoryW(sczPath)) | ||
371 | { | 383 | { |
372 | ++cDeletedDirs; | 384 | ++cDeletedDirs; |
373 | 385 | ||
374 | HRESULT hr = PathGetParentPath(wzPath, &sczPath); | 386 | hr = PathGetParentPath(sczPath, &sczPath, &cchRoot); |
375 | DirExitOnFailure(hr, "Failed to get parent directory for path: %ls", wzPath); | 387 | DirExitOnFailure(hr, "Failed to get parent directory for path: %ls", sczPath); |
376 | |||
377 | wzPath = sczPath; | ||
378 | } | 388 | } |
379 | 389 | ||
380 | LExit: | 390 | LExit: |