From b2c4600453f926fbfdc63219126930ad39601f25 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 8 Apr 2021 14:06:21 -0700 Subject: Port missing WiX v3 changes --- src/dutil/dirutil.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/dutil/dirutil.cpp') diff --git a/src/dutil/dirutil.cpp b/src/dutil/dirutil.cpp index 81130a8d..b10e71f3 100644 --- a/src/dutil/dirutil.cpp +++ b/src/dutil/dirutil.cpp @@ -352,6 +352,37 @@ LExit: } +/******************************************************************* +DirDeleteEmptyDirectoriesToRoot - removes an empty directory and as many + of its parents as possible. + + Returns: count of directories deleted. +*******************************************************************/ +extern "C" DWORD DAPI DirDeleteEmptyDirectoriesToRoot( + __in_z LPCWSTR wzPath, + __in DWORD /*dwFlags*/ + ) +{ + DWORD cDeletedDirs = 0; + LPWSTR sczPath = NULL; + + while (wzPath && *wzPath && ::RemoveDirectoryW(wzPath)) + { + ++cDeletedDirs; + + HRESULT hr = PathGetParentPath(wzPath, &sczPath); + DirExitOnFailure(hr, "Failed to get parent directory for path: %ls", wzPath); + + wzPath = sczPath; + } + +LExit: + ReleaseStr(sczPath); + + return cDeletedDirs; +} + + /******************************************************************* DirGetCurrent - gets the current directory. -- cgit v1.2.3-55-g6feb