CSC/CPE 3350 Lab 4 Part 1 – Recursive File Search

Download Solution: Click to Download Solution
Solution File Name: CSCCPE3350Lab4Part1RecursiveFileSearch.docx
Unzip Password: prestobear.com

Problem:
There are three requirements for this assignment that contribute to your final grade: the program itself,
comments and style, and GitHub commits.
1. (30 points) The Recursive File Search Program
Note: parameters in [] are optional, parameters in <> are required. The | (pipe) means “or.”
• file_search (25 points)
o Usage: file_search
o Example: file_search .c /home/user/mystuff
 Searches all file and directory names in /home/user/mystuff directory for
occurrences of .c
o Ensure is an absolute path – for simplicity, in your code
you should ensure the provided path starts with a /, but does not end with a /
o may have spaces if called like this:
 file_search “hello there” /home/user/mystuff
 bash, and other shells, understand the “ “ and pass the text as one argument.
o DO NOT OPEN ANY FILES WITH OPEN OR FOPEN, IF YOU ACCIDENTALLY RECURSIVELY
OPEN ALL FILES IN A DIRECTORY FOR WRITING, YOU MAY DESTROY ALL FILES IN YOUR
HOME DIRECTORY; YOU HAVE BEEN WARNED. 
o Your program should print all files and directories whose names contain the search
term. Your program should also print the time it took to do the search. Append a “:” to
directories so they are visually distinguishable from files. Example output for the
command above might be:
/home/user/mystuff/file.c
/home/user/mystuff/.c:  a directory!
/home/user/mystuff/.c/otherfile.c
Time: 25ms
o The elapsed time you print should be from the first call to your recursive function until
right after it completes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.