/** * @file maildir-expunge.cc * @brief Implementation of the Maildir class. * @author Andreas Aardal Hanssen * @date 2002-2005 */ #include "iodevice.h" #include "iofactory.h" #include "maildir.h" #include "maildirmessage.h" #include #include using namespace Binc; void Maildir::expungeMailbox() { if (readOnly) return; Mailbox::iterator i = begin(SequenceSet::all(), SQNR_MODE | INCLUDE_EXPUNGED); for (bool success = true; success && i != end(); ++i) { MaildirMessage &message = reinterpret_cast(*i); if ((message.getStdFlags() & Message::F_DELETED) == 0) continue; message.setExpunged(); const std::string &id = message.getUnique(); // The message might be gone already MaildirIndexItem *item = index.find(id); if (!item) continue; std::string fpath = path + "/cur/" + item->fileName; while (unlink(fpath.c_str()) != 0) { if (errno != ENOENT) { bincWarning << "unable to remove " << fpath << ": " << strerror(errno) << std::endl; break; } if (!scanFileNames()) { success = false; break; } if ((item = index.find(id))) break; else fpath = path + "/cur/" + item->fileName; } } }