CS 355 - Systems Programming Lab 6 - implementing find
Objective: write a program that can traverse a tree of subdirectories and search for a file with a given name.
- Write a C program myfind whose behavior resembles that of the system command find.
- myfind accepts the following parameters:
$ myfind filename startpath
where
- filename is a substring that is matched against each filename in each directory that myfind inspects. If a file name matches filename or if the substring filename occurs within a file name, the name of that file is printed.
- startpath is an optional parameter that specifies the directory where myfind must start the search. If this parameter is not specified, myfind starts in the current directory.
For each file whose name is a match, myfind must print its name and its mode.
For each directory in which myfind finds a match, it must print that directory's full path.
Test myfind using various directories on your computer attempting to match full and partial file names. Below is a typical output produced by myfind
$ myfind test
/users/stan/home
test.c (0644/-rw-r--r--)
test.o (0755/-rwxr-xr-x)
testfile.txt (0644/-rw-r--r--)
mytest.c (0644/-rw-r--r--)
/users/stan/home/dirA
test1.txt (0644/-rw-r--r--)
/users/stan/home/dirA/dirA1/dirA1a
mytest.txt (0644/-rw-r--r--)
/users/stan/home/dirB/dirB1
oldtest24.c (0644/-rw-r--r--)
Note: you are not allowed to use ftw() or any similar library function.
- A single C source code file with your work.
- Several screenshots (in PNG or JPG format) showing the results of executing the test cases listed above on a Linux terminal.