blob: 0bde999f53860a33c026fd9074d7d22edcd39d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/** --------------------------------------------------------------------
* @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 <iomanip>
#include <iostream>
#include <errno.h>
#include <dirent.h>
#include <unistd.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;
}
|