-----------------------------------------------------------------------------
| 346 | |
| 347 | //----------------------------------------------------------------------------- |
| 348 | static bool RecurseDumpPath(const char *path, const char* relativePath, const char *pattern, Vector<Platform::FileInfo> &fileVector, S32 currentDepth = 0, S32 recurseDepth = -1) |
| 349 | { |
| 350 | char search[1024]; |
| 351 | |
| 352 | dSprintf(search, sizeof(search), "%s", path, pattern); |
| 353 | |
| 354 | DIR *directory = opendir(search); |
| 355 | |
| 356 | if (directory == NULL) |
| 357 | return false; |
| 358 | |
| 359 | struct dirent *fEntry; |
| 360 | fEntry = readdir(directory); // read the first "file" in the directory |
| 361 | |
| 362 | if (fEntry == NULL) |
| 363 | { |
| 364 | closedir(directory); |
| 365 | return false; |
| 366 | } |
| 367 | |
| 368 | do |
| 369 | { |
| 370 | char filename[BUFSIZ+1]; |
| 371 | struct stat fStat; |
| 372 | |
| 373 | dSprintf(filename, sizeof(filename), "%s/%s", search, fEntry->d_name); // "construct" the file name |
| 374 | stat(filename, &fStat); // get the file stats |
| 375 | |
| 376 | if ( (fStat.st_mode & S_IFMT) == S_IFDIR ) |
| 377 | { |
| 378 | // Directory |
| 379 | // skip . and .. directories |
| 380 | if (dStrcmp(fEntry->d_name, ".") == 0 || dStrcmp(fEntry->d_name, "..") == 0) |
| 381 | continue; |
| 382 | |
| 383 | // skip excluded directories |
| 384 | if( Platform::isExcludedDirectory(fEntry->d_name)) |
| 385 | continue; |
| 386 | |
| 387 | |
| 388 | char child[MaxPath]; |
| 389 | dSprintf(child, sizeof(child), "%s/%s", path, fEntry->d_name); |
| 390 | char* childRelative = NULL; |
| 391 | char childRelativeBuf[MaxPath]; |
| 392 | if (relativePath) |
| 393 | { |
| 394 | dSprintf(childRelativeBuf, sizeof(childRelativeBuf), "%s/%s", |
| 395 | relativePath, fEntry->d_name); |
| 396 | childRelative = childRelativeBuf; |
| 397 | } |
| 398 | if (currentDepth < recurseDepth || recurseDepth == -1 ) |
| 399 | RecurseDumpPath(child, childRelative, pattern, fileVector, currentDepth+1, recurseDepth); |
| 400 | } |
| 401 | else |
| 402 | { |
| 403 | // File |
| 404 | |
| 405 | // add it to the list |