diff options
Diffstat (limited to 'src/maildir-updateflags.cc')
-rw-r--r-- | src/maildir-updateflags.cc | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/maildir-updateflags.cc b/src/maildir-updateflags.cc index a3d2ab7..ba18f82 100644 --- a/src/maildir-updateflags.cc +++ b/src/maildir-updateflags.cc @@ -1,9 +1,10 @@ -/** -------------------------------------------------------------------- +/** * @file maildir-updateflags.cc * @brief Implementation of the Maildir class. * @author Andreas Aardal Hanssen * @date 2002-2005 - * ----------------------------------------------------------------- **/ + */ + #include "iodevice.h" #include "iofactory.h" #include "maildir.h" @@ -13,9 +14,8 @@ #include <dirent.h> #include <unistd.h> -using namespace ::std; +using std::string; -//------------------------------------------------------------------------ void Binc::Maildir::updateFlags(void) { // don't update a read-only mailbox. @@ -24,15 +24,15 @@ void Binc::Maildir::updateFlags(void) // open the cur/ directory string curpath = path + "/cur/"; DIR *pdir = opendir(curpath.c_str()); - if (pdir == 0) { - bincError << "failed to open " << curpath << ": " << strerror(errno) << endl; + if (pdir == nullptr) { + bincError << "failed to open " << curpath << ": " << strerror(errno) << std::endl; return; } // read all entries in the directory - vector<string> entries; + std::vector<string> entries; struct dirent *pdirent; - while ((pdirent = readdir(pdir)) != 0) { + while ((pdirent = readdir(pdir)) != nullptr) { string filename = pdirent->d_name; if (filename[0] == '.') continue; entries.push_back(filename); @@ -41,11 +41,8 @@ void Binc::Maildir::updateFlags(void) bool customFlagsChanged = false; - // loop through all messages in cur/, and update the flags that have - // changed. - for (vector<string>::const_iterator it = entries.begin(); it != entries.end(); ++it) { - string filename = *it; - + // loop through all messages in cur/, and update the flags that have changed. + for (const auto &filename : entries) { // separate the unique name from the flags. accept messages that do not // contain the flags section. string uniquename; @@ -83,8 +80,8 @@ void Binc::Maildir::updateFlags(void) if (rename(srcname.c_str(), destname.c_str()) != 0) { if (errno == ENOENT) { closedir(pdir); - if ((pdir = opendir(curpath.c_str())) == 0) { - bincError << "failed to open " << curpath << ": " << strerror(errno) << endl; + if ((pdir = opendir(curpath.c_str())) == nullptr) { + bincError << "failed to open " << curpath << ": " << strerror(errno) << std::endl; return; } @@ -94,7 +91,7 @@ void Binc::Maildir::updateFlags(void) } bincError << "failed to rename " << srcname << " to " << destname << ": " << strerror(errno) - << endl; + << std::endl; } else { index.insert(uniquename, 0, uniquename + ":2," + flags); } |