diff options
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -473,7 +473,7 @@ fullRead(int fd, char * buf, int len) | |||
473 | * by the fileAction and dirAction function pointers). | 473 | * by the fileAction and dirAction function pointers). |
474 | */ | 474 | */ |
475 | int | 475 | int |
476 | recursiveAction( const char *fileName, BOOL followLinks, | 476 | recursiveAction( const char *fileName, BOOL recurse, BOOL followLinks, |
477 | int (*fileAction)(const char* fileName), | 477 | int (*fileAction)(const char* fileName), |
478 | int (*dirAction)(const char* fileName)) | 478 | int (*dirAction)(const char* fileName)) |
479 | { | 479 | { |
@@ -481,6 +481,18 @@ recursiveAction( const char *fileName, BOOL followLinks, | |||
481 | struct stat statbuf; | 481 | struct stat statbuf; |
482 | struct dirent* next; | 482 | struct dirent* next; |
483 | 483 | ||
484 | if (!recurse && S_ISDIR(statbuf.st_mode)) { | ||
485 | if (dirAction==NULL) | ||
486 | return(TRUE); | ||
487 | else | ||
488 | return(dirAction(fileName)); | ||
489 | } else { | ||
490 | if (fileAction==NULL) | ||
491 | return(TRUE); | ||
492 | else | ||
493 | return(fileAction(fileName)); | ||
494 | } | ||
495 | |||
484 | if (followLinks) | 496 | if (followLinks) |
485 | status = stat(fileName, &statbuf); | 497 | status = stat(fileName, &statbuf); |
486 | else | 498 | else |
@@ -504,7 +516,7 @@ recursiveAction( const char *fileName, BOOL followLinks, | |||
504 | continue; | 516 | continue; |
505 | } | 517 | } |
506 | sprintf(nextFile, "%s/%s", fileName, next->d_name); | 518 | sprintf(nextFile, "%s/%s", fileName, next->d_name); |
507 | status = recursiveAction(nextFile, followLinks, fileAction, dirAction); | 519 | status = recursiveAction(nextFile, TRUE, followLinks, fileAction, dirAction); |
508 | if (status < 0) { | 520 | if (status < 0) { |
509 | closedir(dir); | 521 | closedir(dir); |
510 | return(FALSE); | 522 | return(FALSE); |