From 1978c49bea5b439d993067c055cec47e70db8fd6 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Sat, 7 Oct 2023 22:33:50 +0200 Subject: minor refactoring --- src/maildir-updateflags.cc | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/maildir-updateflags.cc') 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 #include -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 entries; + std::vector 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::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); } -- cgit v1.2.3