/** * @file maildir-scanfilesnames.cc * @brief Implementation of the Maildir class. * @author Andreas Aardal Hanssen * @date 2002-2005 */ #include "iodevice.h" #include "iofactory.h" #include "maildir.h" #include #include #include #include #include using std::string; bool Binc::Maildir::scanFileNames(void) const { string curpath = path + "/cur/"; DIR *pdir = opendir(curpath.c_str()); if (pdir == nullptr) { setLastError("when scanning mailbox \"" + path + "\": " + string(strerror(errno))); bincWarning << getLastError() << std::endl; return false; } index.clearFileNames(); struct dirent *pdirent; while ((pdirent = readdir(pdir)) != nullptr) { if (!isdigit(pdirent->d_name[0])) continue; string filename = pdirent->d_name; string uniquename; string::size_type pos; if ((pos = filename.find(':')) == string::npos) uniquename = filename; else uniquename = filename.substr(0, pos); index.insert(uniquename, 0, pdirent->d_name); } closedir(pdir); return true; }