Earn Higher Grades With Instant Assignment Help.Ask Question!

C Programming
(5/5)

To implement and test a C program using system calls for files and directories find the popular UNIX command that traverses a file hierarchy

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

To implement and test a C program using system calls for files and directories.

Description

Find is a popular UNIX command that traverses a file hierarchy and performs various functions on each file in the hierarchy. The goal of this project is to implement a program similar to find that supports the following functionality:

 

  1. The program should take the directory name from where to start the file traversal as a command-line argument and print the file hierarchy starting with the directory that is provided by the command-line

  2. If the program is executed without any arguments, the program should print the file hierarchy starting with the current directory where the program is executed. If there are no directories in the current directory only files are listed one per

  3. If there are other directories in the current directory then the directory name is first displayed on a separate line and then the files in that directory are listed one-per-line with one-tab indentation.

  4. If a file is a symbolic link then the program should display the symbolic link name and in parentheses the file name the link points

  5. The program should also support two command-line options:

    1. -s

This should list all files in the file hierarchy with file size greater than or equal to the value specified.

  1. -f

This should list all files in the file hierarchy whose file name or directory name contains the substring specified in the string pattern option.

  1. If both -s and -f options are specified then the program should list only those files that match both criteria. The order of the options should not

Guidelines and Hints

  1. The program must use function pointers similar to Figure 4.22 in the text book to implement the functionality described above. You can use the logic and structure from Figure 4.22 as the starting point to implement this program (make sure to go over the program in Figure 4.22 and understand all the steps performed). However, please note that your final program must compile and execute without any dependencies on the source code provided by the text

  2. You should use a Makefile to compile and build this project and make sure to submit the Makefile along with the rest of the source

  3. You should create a tar file with all the source code, Makefile, and a README file and upload the tar file to Canvas. Please do not include any object files or executable files in the tar

 

Program Documentation and Testing

 

  1. Use appropriate names for variables and

  2. Include meaningful comments to indicate various operations performed by the program.

  3. Programs must include the following header information within comments

  4. Test your program with the sample test cases provided as well as your own test cases.

  5. You can include any comments you may have about testing in the README

 

Examples

 

Command

Description

 

$ ./find

 

List all files in the current directory where the program is executed.

 

$ ./find ../programs

 

List all files in the directory ../programs (relative to the current directory)

 

$./find

/home/UAB/puri/CS332/programs

 

List all files in the directory

/home/UAB/puri/CS332/programs (absolute path)

 

$./find -s 1024

 

List all files with size >= 1024 bytes in the current directory

 

$./find -s 1024 ../programs

 

List all files with size >= 1024 bytes in the

../programs (relative to the current directory)

 

$./find -f jpg

 

List all files that have the substring “jpg” in their filename or directory name in the current directory

 

 

$./find -f jpg -s 1024

List all files that have the substring “jpg” in their filename or directory name with size >= 1024 in the current directory

 

 

$./find -s 1024 -f jpg

 

List all files with size >= 1024 and have the substring “jpg” in their filename or directory name in the current directory

Sample Input and Output:

If you have the following directory structure as shown by the output of "ls -lR" command

Then the output of find without any argument should look like this

It is not necessary that the order of the files are exactly as shown above, but the overall structure should look similar to the output shown above. You can use the following tar file to create the directory structure: projects.tar. Download this file and extract the file using the command

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
722 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
530 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
806 Answers Hire Me