diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-06 13:04:55 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-06 13:04:55 +0400 |
commit | 9d3aba7b37b275350a9fe0887871da9ba73dcbd7 (patch) | |
tree | ef6575073c089aaedbce47b63d13836552b4e556 /utility.c | |
parent | b09c6b5d4a204dc89bbab702509b148602027ecd (diff) |
more stuff
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); |