summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-16 15:08:28 -0700
committerJohn Denker <jsd@av8n.com>2012-07-16 15:08:28 -0700
commita73009734a8f795d3c1fabe3a4cfc43501010464 (patch)
tree776ef7bd4266de2c83d17f19b3cc01475ecb620e /tools
parent3e40c30e59db4f060d8f95fca0d5cded75e7ba64 (diff)
automatically skip directories mentioned in the file-list
Also, some better error messages
Diffstat (limited to 'tools')
-rw-r--r--tools/mail-scan.c17
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;