diff options
Diffstat (limited to 'src/dutil/dirutil.cpp')
| -rw-r--r-- | src/dutil/dirutil.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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 | |||
| @@ -353,6 +353,37 @@ LExit: | |||
| 353 | 353 | ||
| 354 | 354 | ||
| 355 | /******************************************************************* | 355 | /******************************************************************* |
| 356 | DirDeleteEmptyDirectoriesToRoot - removes an empty directory and as many | ||
| 357 | of its parents as possible. | ||
| 358 | |||
| 359 | Returns: count of directories deleted. | ||
| 360 | *******************************************************************/ | ||
| 361 | extern "C" DWORD DAPI DirDeleteEmptyDirectoriesToRoot( | ||
| 362 | __in_z LPCWSTR wzPath, | ||
| 363 | __in DWORD /*dwFlags*/ | ||
| 364 | ) | ||
| 365 | { | ||
| 366 | DWORD cDeletedDirs = 0; | ||
| 367 | LPWSTR sczPath = NULL; | ||
| 368 | |||
| 369 | while (wzPath && *wzPath && ::RemoveDirectoryW(wzPath)) | ||
| 370 | { | ||
| 371 | ++cDeletedDirs; | ||
| 372 | |||
| 373 | HRESULT hr = PathGetParentPath(wzPath, &sczPath); | ||
| 374 | DirExitOnFailure(hr, "Failed to get parent directory for path: %ls", wzPath); | ||
| 375 | |||
| 376 | wzPath = sczPath; | ||
| 377 | } | ||
| 378 | |||
| 379 | LExit: | ||
| 380 | ReleaseStr(sczPath); | ||
| 381 | |||
| 382 | return cDeletedDirs; | ||
| 383 | } | ||
| 384 | |||
| 385 | |||
| 386 | /******************************************************************* | ||
| 356 | DirGetCurrent - gets the current directory. | 387 | DirGetCurrent - gets the current directory. |
| 357 | 388 | ||
| 358 | *******************************************************************/ | 389 | *******************************************************************/ |
