Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
maildir-expunge.cc
Go to the documentation of this file.
1
7#include <unistd.h>
8#include <errno.h>
9
10#include "iodevice.h"
11#include "iofactory.h"
12#include "maildir.h"
13#include "maildirmessage.h"
14
15using namespace ::std;
16using namespace Binc;
17
18//------------------------------------------------------------------------
20{
21 if (readOnly) return;
22
24
25 bool success = true;
26 for (; success && i != end(); ++i) {
27 MaildirMessage &message = reinterpret_cast<MaildirMessage &>(*i);
28
29 if ((message.getStdFlags() & Message::F_DELETED) == 0)
30 continue;
31
32 message.setExpunged();
33
34 const string &id = message.getUnique();
35
36 // The message might be gone already
37 MaildirIndexItem *item = index.find(id);
38 if (!item)
39 continue;
40
41 string fpath = path + "/cur/" + item->fileName;
42
43 while (unlink(fpath.c_str()) != 0) {
44 if (errno != ENOENT) {
45 bincWarning << "unable to remove " << fpath << ": "
46 << strerror(errno) << endl;
47 break;
48 }
49
50 if (!scanFileNames()) {
51 success = false;
52 break;
53 }
54
55 if ((item = index.find(id)))
56 break;
57 else
58 fpath = path + "/cur/" + item->fileName;
59 }
60 }
61}
bool readOnly
Definition: mailbox.h:125
@ INCLUDE_EXPUNGED
Definition: mailbox.h:68
Mailbox::iterator end(void) const
Definition: maildir.cc:156
void expungeMailbox(void)
bool scanFileNames(void) const
Mailbox::iterator begin(const SequenceSet &bset, unsigned int mod=INCLUDE_EXPUNGED|SQNR_MODE) const
Definition: maildir.cc:146
MaildirIndexItem * find(const std::string &unique)
Definition: maildir.cc:810
std::string fileName
Definition: maildir.h:34
The MaildirMessage class provides an interface for IMAP messages.
const std::string & getUnique(void) const
unsigned char getStdFlags(void) const
static SequenceSet & all(void)
Definition: imapparser.cc:261
Declaration of the IODevice class.
Declaration of the IOFactory class.
#define bincWarning
Definition: iofactory.h:44
Declaration of the Maildir class.
Declaration of the MaildirMessage class.
Definition: bincimapd.cc:9