summaryrefslogtreecommitdiff
path: root/src/maildir-scanfilesnames.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/maildir-scanfilesnames.cc')
-rw-r--r--src/maildir-scanfilesnames.cc53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/maildir-scanfilesnames.cc b/src/maildir-scanfilesnames.cc
new file mode 100644
index 0000000..643460b
--- /dev/null
+++ b/src/maildir-scanfilesnames.cc
@@ -0,0 +1,53 @@
+/** --------------------------------------------------------------------
+ * @file maildir-scanfilesnames.cc
+ * @brief Implementation of the Maildir class.
+ * @author Andreas Aardal Hanssen
+ * @date 2002-2005
+ * ----------------------------------------------------------------- **/
+#include "maildir.h"
+
+#include <iostream>
+#include <iomanip>
+
+#include <dirent.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "iodevice.h"
+#include "iofactory.h"
+
+using namespace ::std;
+
+//------------------------------------------------------------------------
+bool Binc::Maildir::scanFileNames(void) const
+{
+ string curpath = path + "/cur/";
+ DIR *pdir = opendir(curpath.c_str());
+ if (pdir == 0) {
+ setLastError("when scanning mailbox \""
+ + path + "\": " + string(strerror(errno)));
+ bincWarning << getLastError() << endl;
+ return false;
+ }
+
+ index.clearFileNames();
+
+ struct dirent *pdirent;
+ while ((pdirent = readdir(pdir)) != 0) {
+ 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;
+}