Question: please write the code by C L1: Filesystem searcher Required compiler flags: -Wall -fsanitize=address, undefined Write a program that searches provided directories and its sub-directories
please write the code by C
L1: Filesystem searcher Required compiler flags: -Wall -fsanitize=address, undefined Write a program that searches provided directories and its sub-directories in order to find all the regular files which contain given string in their names. The program should list all found files which satisfy searching criteria with their sizes. The program is run as follows: ./prog -p ./dir -p ./dir2 -d 2 -w abc -s 23 -o output. -p flag is used to provide each directory path -d flag is used to determine the depth limit of searching. For example if d is 2 and path is ./mainDir then the program should work on ./mainDir, all direct sub-folders of ./mainDir e.g. ./mainDir/dir1, ./mainDir/dir2 but not on sub-folders like ./mainDir/dir2/dirA. If d is not specified we should search without depth limit. -w flag is used for specify searching word in files names .-s flag is used for specify minimum size of searching files .-o flag is used for specify name of output file. If it is not specified we want to print result on stdout otherwise to the given file (overwrite if already exists) Options should be given in described order. Option -p can be given multiple times. If there is no files satisfying given criteria or given arguments are wrong program should write proper message about it. Stages: 1. 5 p. Program works for -d 1 2. 3 p. Option -o works 3. 4 p. Option -s works 4. 5 p. Program works for any -d (also not specified)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
