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) * by the fileAction and dirAction function pointers). */ int -recursiveAction( const char *fileName, BOOL followLinks, +recursiveAction( const char *fileName, BOOL recurse, BOOL followLinks, int (*fileAction)(const char* fileName), int (*dirAction)(const char* fileName)) { @@ -481,6 +481,18 @@ recursiveAction( const char *fileName, BOOL followLinks, struct stat statbuf; struct dirent* next; + if (!recurse && S_ISDIR(statbuf.st_mode)) { + if (dirAction==NULL) + return(TRUE); + else + return(dirAction(fileName)); + } else { + if (fileAction==NULL) + return(TRUE); + else + return(fileAction(fileName)); + } + if (followLinks) status = stat(fileName, &statbuf); else @@ -504,7 +516,7 @@ recursiveAction( const char *fileName, BOOL followLinks, continue; } sprintf(nextFile, "%s/%s", fileName, next->d_name); - status = recursiveAction(nextFile, followLinks, fileAction, dirAction); + status = recursiveAction(nextFile, TRUE, followLinks, fileAction, dirAction); if (status < 0) { closedir(dir); return(FALSE); |