Lines 25-30
Link Here
|
25 |
#include <qregexp.h> |
25 |
#include <qregexp.h> |
26 |
#include <stdexcept> |
26 |
#include <stdexcept> |
27 |
#include <dirent.h> |
27 |
#include <dirent.h> |
|
|
28 |
#include <sys/stat.h> |
28 |
#include "utility/progress.h" |
29 |
#include "utility/progress.h" |
29 |
|
30 |
|
30 |
|
31 |
|
Lines 304-315
Link Here
|
304 |
else |
305 |
else |
305 |
realdir = directory; |
306 |
realdir = directory; |
306 |
|
307 |
|
307 |
try |
|
|
308 |
{ |
309 |
dir = opendir(realdir.c_str()); |
308 |
dir = opendir(realdir.c_str()); |
310 |
if (dir == NULL) |
309 |
if (dir == NULL) |
311 |
throw runtime_error(("could not open directory: "+directory).c_str()); |
310 |
throw runtime_error(("could not open directory: "+directory).c_str()); |
312 |
|
311 |
|
|
|
312 |
try |
313 |
{ |
313 |
while ((entry = readdir(dir))) |
314 |
while ((entry = readdir(dir))) |
314 |
{ |
315 |
{ |
315 |
if (strcmp(entry->d_name, ".") == 0) |
316 |
if (strcmp(entry->d_name, ".") == 0) |
Lines 318-333
Link Here
|
318 |
continue; |
319 |
continue; |
319 |
if (prog) |
320 |
if (prog) |
320 |
prog->setProgress(prog->progress() + 1); |
321 |
prog->setProgress(prog->progress() + 1); |
321 |
if (entry->d_type == DT_DIR) |
322 |
string full_name = realdir + "/" + entry->d_name; |
322 |
enumerateFiles(realdir + "/" + entry->d_name, result, prog); |
323 |
|
323 |
else if (entry->d_type == DT_REG) |
324 |
struct stat my_statbuf; |
324 |
result.push_back(realdir + "/" + entry->d_name); |
325 |
if (stat(full_name.c_str(), &my_statbuf) != 0) |
|
|
326 |
{ |
327 |
cerr |
328 |
<< "*** Failed to stat:" << endl |
329 |
<< "*** " << full_name << endl; |
330 |
continue; |
331 |
} |
332 |
|
333 |
if (S_ISDIR(my_statbuf.st_mode)) |
334 |
enumerateFiles(full_name, result, prog); |
335 |
else if (S_ISREG(my_statbuf.st_mode)) |
336 |
result.push_back(full_name); |
325 |
} |
337 |
} |
326 |
closedir(dir); |
338 |
closedir(dir); |
327 |
} |
339 |
} |
328 |
catch (...) |
340 |
catch (...) |
329 |
{ |
341 |
{ |
330 |
closedir(dir); |
342 |
closedir(dir); |
|
|
343 |
throw; |
331 |
} |
344 |
} |
332 |
} |
345 |
} |
333 |
|
346 |
|