+ return 0;
+ }
+
+ // According to POSIX, the dirent structure contains a field char d_name[]
+ // of unspecified size, with at most NAME_MAX characters preceding the
+ // terminating null character. Use of other fields will harm the porta-
+ // bility of your programs.
+
+ struct stat buf;
+ dirent* d = 0;
+ for (d = readdir(dir); d; d = readdir(dir))
+ {
+ fileName = dirName + d->d_name;
+ stat(fileName.c_str(), &buf); //really discard output ?
+ if( S_ISREG(buf.st_mode) ) //is it a regular file?
+ {
+ push_back( fileName );
+ numberOfFiles++;
+ }
+ else if( S_ISDIR(buf.st_mode) ) //directory?