From 6b65375ee5b3990ec6764dbd71c02b7d9931b660 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 28 Jan 2017 17:23:15 -0500 Subject: [PATCH] Bug1521, bug1567 Mac: wipe .DS_Store in temp folder when saving too --- src/DirManager.cpp | 18 ++++++++++-------- src/DirManager.h | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/DirManager.cpp b/src/DirManager.cpp index 9cfa3bed6..8ae4c340b 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -398,6 +398,13 @@ DirManager::~DirManager() // static void DirManager::CleanTempDir() +{ + CleanDir(globaltemp, wxT("project*"), _("Cleaning up temporary files")); +} + +// static +void DirManager::CleanDir( + const wxString &path, const wxString &dirSpec, const wxString &msg) { if (dontDeleteTempFiles) return; // do nothing @@ -407,9 +414,9 @@ void DirManager::CleanTempDir() // Subtract 1 because we don't want to DELETE the global temp directory, // which this will find and list last. int countFiles = - RecursivelyEnumerate(globaltemp, filePathArray, wxT("project*"), true, false); + RecursivelyEnumerate(path, filePathArray, dirSpec, true, false); int countDirs = - RecursivelyEnumerate(globaltemp, dirPathArray, wxT("project*"), false, true) - 1; + RecursivelyEnumerate(path, dirPathArray, dirSpec, false, true) - 1; // Remove the globaltemp itself from the array dirPathArray.resize(countDirs); @@ -417,7 +424,6 @@ void DirManager::CleanTempDir() if (count == 0) return; - auto msg = _("Cleaning up temporary files"); RecursivelyRemove(filePathArray, count, 0, true, false, msg); RecursivelyRemove(dirPathArray, count, countFiles, false, true, msg); } @@ -541,15 +547,11 @@ 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. - wxArrayString dirlist; - const int count = RecursivelyEnumerate(cleanupLoc1, dirlist, wxEmptyString, false, true); + CleanDir(cleanupLoc1, wxEmptyString, _("Cleaning up cache directories")); //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) // count += RecursivelyEnumerate(cleanupLoc2, dirlist, wxEmptyString, false, true); - - if (count > 0) - RecursivelyRemove(dirlist, count, 0, false, true, _("Cleaning up cache directories")); } return true; } diff --git a/src/DirManager.h b/src/DirManager.h index d2f67d64c..5a6825a0b 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -122,6 +122,8 @@ class PROFILE_DLL_API DirManager final : public XMLTagHandler { // dir is not cleaned at start up anymore. But it is cleaned when the // program is exited normally. static void CleanTempDir(); + static void CleanDir( + const wxString &path, const wxString &dirSpec, const wxString &msg); // Check the project for errors and possibly prompt user // bForceError: Always show log error alert even if no errors are found here.