Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
maildir-scanfilesnames.cc
Go to the documentation of this file.
1
7#include "maildir.h"
8
9#include <iostream>
10#include <iomanip>
11
12#include <dirent.h>
13#include <unistd.h>
14#include <errno.h>
15
16#include "iodevice.h"
17#include "iofactory.h"
18
19using namespace ::std;
20
21//------------------------------------------------------------------------
23{
24 string curpath = path + "/cur/";
25 DIR *pdir = opendir(curpath.c_str());
26 if (pdir == 0) {
27 setLastError("when scanning mailbox \""
28 + path + "\": " + string(strerror(errno)));
29 bincWarning << getLastError() << endl;
30 return false;
31 }
32
33 index.clearFileNames();
34
35 struct dirent *pdirent;
36 while ((pdirent = readdir(pdir)) != 0) {
37 if (!isdigit(pdirent->d_name[0])) continue;
38
39 string filename = pdirent->d_name;
40 string uniquename;
41
42 string::size_type pos;
43 if ((pos = filename.find(':')) == string::npos)
44 uniquename = filename;
45 else
46 uniquename = filename.substr(0, pos);
47
48 index.insert(uniquename, 0, pdirent->d_name);
49 }
50
51 closedir(pdir);
52 return true;
53}
void setLastError(const std::string &error) const
Definition: mailbox.cc:109
const std::string & getLastError(void) const
Definition: mailbox.cc:103
bool scanFileNames(void) const
void clearFileNames(void)
Definition: maildir.cc:834
void insert(const std::string &unique, unsigned int uid, const std::string &fileName="")
Definition: maildir.cc:786
Declaration of the IODevice class.
Declaration of the IOFactory class.
#define bincWarning
Definition: iofactory.h:44
Declaration of the Maildir class.