22 char *safename = strdup((path +
"/.bincimap-cache-tmp-XXXXXX").c_str());
23 int fd = mkstemp(safename);
29 string safeName = safename;
32 FILE *fp = fdopen(fd,
"w");
34 unlink(safeName.c_str());
38 if (uidvalidity == 0 || uidnext == 0) {
39 uidvalidity = time(0);
40 uidnext = messages.size() + 1;
43 fprintf(fp,
"%s %u %u\n",
BINC_CACHE, uidvalidity, uidnext);
45 for (; i !=
end(); ++i) {
47 fprintf(fp,
"%u %u %u %s", message.
getUID(),
51 for (vector<string>::const_iterator it = cflags.begin();
52 it != cflags.end(); ++it) {
53 fprintf(fp,
" %s", (*it).c_str());
58 if (fflush(fp) || (fsync(fd) && (errno != EROFS || errno != EINVAL)) || fclose(fp)) {
59 unlink(safeName.c_str());
63 if (rename(safeName.c_str(), (path +
"/bincimap-cache").c_str()) != 0) {
64 unlink(safeName.c_str());
68 int dfd = open(path.c_str(), O_RDONLY);
69 if (dfd == -1 || (fsync(fd) && (errno != EROFS || errno != EINVAL)) || close(dfd)) {
Mailbox::iterator end(void) const
Mailbox::iterator begin(const SequenceSet &bset, unsigned int mod=INCLUDE_EXPUNGED|SQNR_MODE) const
The MaildirMessage class provides an interface for IMAP messages.
std::vector< std::string > getCustomFlags(void) const
unsigned int getSize(bool determine=false) const
unsigned int getUID(void) const
const std::string & getUnique(void) const
time_t getInternalDate(void) const
static SequenceSet & all(void)
Declaration of the Maildir class.