diff options
author | Vincent Richard <[email protected]> | 2005-11-27 21:02:50 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2005-11-27 21:02:50 +0000 |
commit | 594dfdbd55b60d8494676fba652e66f7a7a38af7 (patch) | |
tree | 3f0cbce2595f21480c47315b0f88a2f2f9f96755 /src | |
parent | GNU TLS detection with SCons. (diff) | |
download | vmime-594dfdbd55b60d8494676fba652e66f7a7a38af7.tar.gz vmime-594dfdbd55b60d8494676fba652e66f7a7a38af7.zip |
Fixed problem with maildir and ':' in filename on Windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/maildir/maildirUtils.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp index 1ee29a4a..32d69948 100644 --- a/src/net/maildir/maildirUtils.cpp +++ b/src/net/maildir/maildirUtils.cpp @@ -102,11 +102,29 @@ const bool maildirUtils::isMessageFile(const utility::file& file) } +// NOTE ABOUT ID/FLAGS SEPARATOR +// ----------------------------- +// In the maildir specification, the character ':' is used to separate +// the unique identifier and the message flags. +// +// On Windows (and particularly FAT file systems), ':' is not allowed +// in a filename, so we use a dash ('-') instead. This is the solution +// used by Mutt/Win32, so we also use it here. +// +// To be compatible between implementations, we check for both +// characters when reading file names. + + const utility::file::path::component maildirUtils::extractId (const utility::file::path::component& filename) { - string::size_type sep = filename.getBuffer().rfind(':'); - if (sep == string::npos) return (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))); @@ -115,8 +133,13 @@ const utility::file::path::component maildirUtils::extractId const int maildirUtils::extractFlags(const utility::file::path::component& comp) { - string::size_type sep = comp.getBuffer().rfind(':'); - if (sep == string::npos) return (0); + 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(); @@ -166,7 +189,11 @@ const utility::file::path::component maildirUtils::buildFilename const utility::file::path::component maildirUtils::buildFilename (const utility::file::path::component& id, const utility::file::path::component& flags) { - return (utility::path::component(id.getBuffer() + ":" + flags.getBuffer())); +#if VMIME_BUILTIN_PLATFORM_WINDOWS + return (utility::path::component(id.getBuffer() + "-" + flags.getBuffer())); // use dash +#else + return (utility::path::component(id.getBuffer() + ":" + flags.getBuffer())); // use colon +#endif } |