int maildirUtils::extractFlags(const utility::file::path::component& comp) { string::size_type sep = comp.getBuffer().rfind(':'); // try colon if (sep == string::npos) { sep = comp.getBuffer().rfind('-'); // try dash (Windows) if (sep == string::npos) return 0; } const string flagsString(comp.getBuffer().begin() + sep + 1, comp.getBuffer().end()); const string::size_type count = flagsString.length(); int flags = 0; for (string::size_type i = 0 ; i < count ; ++i) { switch (flagsString[i]) { case 'R': case 'r': flags |= message::FLAG_REPLIED; break; case 'S': case 's': flags |= message::FLAG_SEEN; break; case 'T': case 't': flags |= message::FLAG_DELETED; break; case 'F': case 'f': flags |= message::FLAG_MARKED; break; case 'P': case 'p': flags |= message::FLAG_PASSED; break; case 'D': case 'd': flags |= message::FLAG_DRAFT; break; } } return (flags); }
const utility::file::path::component maildirUtils::buildFilename (const utility::file::path::component& id, const utility::file::path::component& flags) { #if VMIME_PLATFORM_IS_WINDOWS static const char DELIMITER[] = "-"; #else static const char DELIMITER[] = ":"; #endif return utility::path::component(id.getBuffer() + DELIMITER + flags.getBuffer()); }
const utility::file::path::component maildirUtils::extractId (const utility::file::path::component& filename) { string::size_type sep = filename.getBuffer().rfind(':'); // try colon if (sep == string::npos) { sep = filename.getBuffer().rfind('-'); // try dash (Windows) if (sep == string::npos) return (filename); } return (utility::path::component (string(filename.getBuffer().begin(), filename.getBuffer().begin() + sep))); }