diff options
| author | Vincent Richard <[email protected]> | 2006-04-23 08:48:19 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2006-04-23 08:48:19 +0000 |
| commit | 6933fb8a30cf17ae90394fca5114b8e600ef2cfd (patch) | |
| tree | 7f35e7226f7179993eb0a7cbdb9953a4fa19fa26 /src/net/maildir/maildirUtils.cpp | |
| parent | Renamed 'byte' to 'byte_t'. (diff) | |
| download | vmime-6933fb8a30cf17ae90394fca5114b8e600ef2cfd.tar.gz vmime-6933fb8a30cf17ae90394fca5114b8e600ef2cfd.zip | |
Folder deletion.
Diffstat (limited to 'src/net/maildir/maildirUtils.cpp')
| -rw-r--r-- | src/net/maildir/maildirUtils.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp index c0594a31..00a9a7b1 100644 --- a/src/net/maildir/maildirUtils.cpp +++ b/src/net/maildir/maildirUtils.cpp @@ -22,6 +22,9 @@ #include "vmime/utility/random.hpp" +#include "vmime/exception.hpp" +#include "vmime/platformDependant.hpp" + namespace vmime { namespace net { @@ -212,6 +215,44 @@ const utility::file::path::component maildirUtils::generateId() } +void maildirUtils::recursiveFSDelete(ref <utility::file> dir) +{ + ref <utility::fileIterator> files = dir->getFiles(); + + // First, delete files and subdirectories in this directory + while (files->hasMoreElements()) + { + ref <utility::file> file = files->nextElement(); + + if (file->isDirectory()) + { + maildirUtils::recursiveFSDelete(file); + } + else + { + try + { + file->remove(); + } + catch (exceptions::filesystem_exception&) + { + // Ignore + } + } + } + + // Then, delete this (empty) directory + try + { + dir->remove(); + } + catch (exceptions::filesystem_exception&) + { + // Ignore + } +} + + // // messageIdComparator |
