diff options
Diffstat (limited to 'find.c')
| -rw-r--r-- | find.c | 25 |
1 files changed, 1 insertions, 24 deletions
| @@ -42,34 +42,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) | |||
| 42 | { | 42 | { |
| 43 | if (pattern==NULL) | 43 | if (pattern==NULL) |
| 44 | fprintf(stdout, "%s\n", fileName); | 44 | fprintf(stdout, "%s\n", fileName); |
| 45 | else if (find_match(fileName, pattern, TRUE) == TRUE) | 45 | else if (find_match((char*)fileName, pattern, TRUE) == TRUE) |
| 46 | fprintf(stdout, "%s\n", fileName); | 46 | fprintf(stdout, "%s\n", fileName); |
| 47 | return( TRUE); | 47 | return( TRUE); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static int dirAction(const char *fileName, struct stat* statbuf) | ||
| 51 | { | ||
| 52 | DIR *dir; | ||
| 53 | struct dirent *entry; | ||
| 54 | |||
| 55 | if (pattern==NULL) | ||
| 56 | fprintf(stdout, "%s\n", fileName); | ||
| 57 | else if (find_match(fileName, pattern, TRUE) == TRUE) | ||
| 58 | fprintf(stdout, "%s\n", fileName); | ||
| 59 | |||
| 60 | dir = opendir( fileName); | ||
| 61 | if (!dir) { | ||
| 62 | perror("Can't open directory"); | ||
| 63 | exit(FALSE); | ||
| 64 | } | ||
| 65 | while ((entry = readdir(dir)) != NULL) { | ||
| 66 | char dirName[NAME_MAX]; | ||
| 67 | sprintf(dirName, "%s/%s", fileName, entry->d_name); | ||
| 68 | recursiveAction( dirName, TRUE, dereferenceFlag, FALSE, fileAction, dirAction); | ||
| 69 | } | ||
| 70 | return( TRUE); | ||
| 71 | } | ||
| 72 | |||
| 73 | int find_main(int argc, char **argv) | 50 | int find_main(int argc, char **argv) |
| 74 | { | 51 | { |
| 75 | /* peel off the "find" */ | 52 | /* peel off the "find" */ |
