summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorEric Andersen1999-10-06 09:04:55 +0000
committerEric Andersen1999-10-06 09:04:55 +0000
commit9d3aba7b37b275350a9fe0887871da9ba73dcbd7 (patch)
treeef6575073c089aaedbce47b63d13836552b4e556 /utility.c
parentb09c6b5d4a204dc89bbab702509b148602027ecd (diff)
downloadbusybox-9d3aba7b37b275350a9fe0887871da9ba73dcbd7.zip
busybox-9d3aba7b37b275350a9fe0887871da9ba73dcbd7.tar.gz
more stuff
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/utility.c b/utility.c
index a516355..c8f58e8 100644
--- a/utility.c
+++ b/utility.c
@@ -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);