diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mail-scan.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/mail-scan.c b/tools/mail-scan.c index c2b798b..5ec2b25 100644 --- a/tools/mail-scan.c +++ b/tools/mail-scan.c @@ -15,6 +15,9 @@ #include <signal.h> #include <fstream> +#include <sys/types.h> /* for stat() */ +#include <sys/stat.h> /* stat() */ + #include <stdio.h> /* perror */ using namespace std; @@ -182,6 +185,15 @@ int main(int _argc, const char** _argv){ for (list<string>::const_iterator file = dofile.begin(); file != dofile.end(); file++) { + + + struct stat filestatus; + stat(file->c_str(), &filestatus ); + if (S_ISDIR(filestatus.st_mode)) { + cerr << "is directory: " << *file << endl; + continue; + } + ifstream infile; infile.open(file->c_str()); if (!infile.good()) { @@ -198,7 +210,10 @@ int main(int _argc, const char** _argv){ string line; for (;;) { // loop over all lines in this record if (infile.eof()) break; - if (infile.bad()) return 1; + if (infile.bad()) { + cerr << "mail-scan: read error on file '" << *file << "'" << endl; + return 1; + } if (getline(infile, line).fail()) continue; Header.push_back(line); msgsize += line.length()+1; |