--- base.cpp 2005-08-17 17:47:49 +0300 +++ base.cpp.new 2005-08-17 17:58:45 +0300 @@ -25,6 +25,7 @@ #include #include #include +#include #include "utility/progress.h" @@ -304,12 +305,12 @@ else realdir = directory; - try - { dir = opendir(realdir.c_str()); if (dir == NULL) throw runtime_error(("could not open directory: "+directory).c_str()); + try + { while ((entry = readdir(dir))) { if (strcmp(entry->d_name, ".") == 0) @@ -318,16 +319,28 @@ continue; if (prog) prog->setProgress(prog->progress() + 1); - if (entry->d_type == DT_DIR) - enumerateFiles(realdir + "/" + entry->d_name, result, prog); - else if (entry->d_type == DT_REG) - result.push_back(realdir + "/" + entry->d_name); + string full_name = realdir + "/" + entry->d_name; + + struct stat my_statbuf; + if (stat(full_name.c_str(), &my_statbuf) != 0) + { + cerr + << "*** Failed to stat:" << endl + << "*** " << full_name << endl; + continue; + } + + if (S_ISDIR(my_statbuf.st_mode)) + enumerateFiles(full_name, result, prog); + else if (S_ISREG(my_statbuf.st_mode)) + result.push_back(full_name); } closedir(dir); } catch (...) { closedir(dir); + throw; } }