Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmPreferences: Clean up and delete account directory on account delete
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 3 Feb 2018 13:24:09 +0000 (13:24 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 3 Feb 2018 13:24:09 +0000 (13:24 +0000)
source/forms/preferences/frmPreferences.cpp
source/forms/preferences/frmPreferences.h

index 07a4715..8157bbb 100644 (file)
@@ -328,7 +328,7 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event )
                        accountDirDelFull.Append(wxT("/.xestiacal/accounts/"));
                        accountDirDelFull.Append(accountDirFull);
        
-                       wxRmDir(accountDirDelFull);
+                       DeleteDirectory(accountDirDelFull);
        
                }
        
@@ -425,4 +425,37 @@ void frmPreferences::SetupPointers(bool *reloadAccountInc){
        
        reloadAccountConfig = reloadAccountInc;
 
-}
\ No newline at end of file
+}
+
+void frmPreferences::DeleteDirectory(wxString directoryPath)
+{
+       
+       // Open the directory and look for files and directories 
+       // to delete.
+       
+       wxDir directoryHandle(directoryPath);
+       
+       if (!directoryHandle.IsOpened())
+       {
+               return;
+       }
+       
+       wxString directoryFilename;
+       
+       bool continueProcessing = directoryHandle.GetFirst(&directoryFilename, wxEmptyString, wxDIR_FILES|wxDIR_DIRS|wxDIR_HIDDEN);
+       while (continueProcessing)
+       {
+               wxString directoryFilenameFull = directoryPath + "/" + directoryFilename;
+               if (wxDir::Exists(directoryFilenameFull))
+               {
+                       DeleteDirectory(directoryFilenameFull);
+                       continueProcessing = directoryHandle.GetNext(&directoryFilename);
+                       continue;
+               }
+               wxRemoveFile(directoryFilenameFull);
+               continueProcessing = directoryHandle.GetNext(&directoryFilename);
+       }
+       directoryHandle.Close();
+       
+       wxRmDir(directoryPath); 
+}
index a5eec97..29f9b90 100644 (file)
@@ -63,6 +63,7 @@ class frmPreferences : public frmPreferencesADT
                void DeleteAccount( wxCommandEvent& event );
                void SavePreferences( wxCommandEvent& event );
                void CloseWindow( wxCommandEvent& event );
+               void DeleteDirectory( wxString directoryPath );
        public:
                /** Constructor */
                frmPreferences( wxWindow* parent );
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy