View | Details | Raw Unified | Return to bug 7672
Collapse All | Expand All

(-)madman-0.93rc2/utility/base.cpp.orig (-6 / +19 lines)
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 319-328 Link Here
319
320
320
      if (prog)
321
      if (prog)
321
        prog->setProgress(prog->progress() + 1);
322
        prog->setProgress(prog->progress() + 1);
322
      if (entry->d_type == DT_DIR)
323
	  string full_name = realdir + "/" + entry->d_name;
323
        enumerateFiles(realdir + "/" + entry->d_name, result, prog);
324
324
      else if (entry->d_type == DT_REG)
325
	  struct stat my_statbuf;
325
        result.push_back(realdir + "/" + entry->d_name);
326
	  if (stat(full_name.c_str(), &my_statbuf) != 0)
327
	  {
328
		cerr
329
		  << "*** Failed to stat:" << endl
330
		  << "*** " << full_name << endl;
331
		continue;
332
	  }
333
334
	  if (S_ISDIR(my_statbuf.st_mode))
335
		enumerateFiles(full_name, result, prog);
336
	  else if (S_ISREG(my_statbuf.st_mode))
337
		result.push_back(full_name);
326
    }
338
    }
327
339
328
    closedir(dir);
340
    closedir(dir);
Lines 330-335 Link Here
330
  catch (...)
342
  catch (...)
331
  {
343
  {
332
    closedir(dir);
344
    closedir(dir);
345
	throw;
333
  }
346
  }
334
}
347
}
335
348

Return to bug 7672