diff --git a/src/DirManager.cpp b/src/DirManager.cpp index 8ae4c340b..2de05f0cf 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -404,7 +404,8 @@ void DirManager::CleanTempDir() // static void DirManager::CleanDir( - const wxString &path, const wxString &dirSpec, const wxString &msg) + const wxString &path, const wxString &dirSpec, const wxString &msg, + bool removeTop) { if (dontDeleteTempFiles) return; // do nothing @@ -416,9 +417,12 @@ void DirManager::CleanDir( int countFiles = RecursivelyEnumerate(path, filePathArray, dirSpec, true, false); int countDirs = - RecursivelyEnumerate(path, dirPathArray, dirSpec, false, true) - 1; - // Remove the globaltemp itself from the array - dirPathArray.resize(countDirs); + RecursivelyEnumerate(path, dirPathArray, dirSpec, false, true); + if (!removeTop) { + // Remove the globaltemp itself from the array + --countDirs; + dirPathArray.resize(countDirs); + } auto count = countFiles + countDirs; if (count == 0) @@ -547,7 +551,8 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const // recurse depth-first and rmdir every directory seen in old and // NEW; rmdir will fail on non-empty dirs. - CleanDir(cleanupLoc1, wxEmptyString, _("Cleaning up cache directories")); + CleanDir( + cleanupLoc1, wxEmptyString, _("Cleaning up cache directories"), true); //This destroys the empty dirs of the OD block files, which are yet to come. //Dont know if this will make the project dirty, but I doubt it. (mchinen) diff --git a/src/DirManager.h b/src/DirManager.h index 5a6825a0b..3f60931bd 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -123,7 +123,8 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { // program is exited normally. static void CleanTempDir(); static void CleanDir( - const wxString &path, const wxString &dirSpec, const wxString &msg); + const wxString &path, const wxString &dirSpec, const wxString &msg, + bool removeTop = false); // Check the project for errors and possibly prompt user // bForceError: Always show log error alert even if no errors are found here.