COMP-8567 Assignment 02 solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (3 votes)

Write a C program extfind , to search for files with specific extensions in a directory hierarchy.
 The first parameter of extfind is the absolute path of the directory/subdirectory
 The remaining parameter/s are the file extensions.
Example: $ extfind /home/pranga/chapter4 txt c should list all the .txt and .c files in
/home/pranga/chapter4 , and also in all of the subdirectories (and their subdirectories if any) in
chapter4. i.e the entire directory subtree with /home/pranga/chapter4 as the root should be
searched for .txt and .c files.
 It is mandatory to provide a valid absolute path as the first parameter to this program
(else the program should print an appropriate error message to standard error and exit)
 In case the file extensions are not provided in the second and subsequent parameters, all
the files in the sub-tree must be listed in the output.
 The extfind command/program should accept 0-10 file extensions.
Output: The absolute path names of all the files found must be printed by the program. If no files
of the specified type are found, appropriate message/s must be printed.
Requirement: – You must use the system call nftw() that allows you to walk across a file tree.
Please read the manual of nftw() before starting your assignment.
Submission: The assignment should be uploaded as a single C file onto Blackboard