Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab, you are required to create a C program which works with command line arguments. The arguments themselves may or may not be

image text in transcribedimage text in transcribedimage text in transcribed

For this lab, you are required to create a C program which works with command line arguments. The arguments themselves may or may not be present on the command line. Your code will have to adapt itself to accommodate for this. The aim of this lab is to familiarize yourself with reading and processing directories as well as extracting file attributes using the stat() system call. You are essentially writing your own version of the Is command. You will need to customize your output to match the following specifications: You program must accept the following parameters (if present): dont filon (modifiantin nifion tha of the Steblod ba You program must accept the following parameters (if present): -O: specifies the age of the oldest files (modification timestamp) to be listed from the target directory. The -o argument will be followed by an integer (as a separate parameter to make things easier if you wish). This integer will represent the minimum number of days old the files can be in order for them to be included in your listing. As an example "-o 3" passed as arguments would mean: list all files that have been modified more than 3 days ago (from the current system time). -y: specifies the age of the newest files (modification timestamp) to be listed from the target directory. The -y argument will be followed by an integer (as a separate parameter to make things easier if you wish). This integer will represent the maximum number of days old the files need to be in order for them to show up in your listing. You can think of the -y to represent YOUNGER THAN. As an example "-y 7" passed as arguments should represent list all files whose modification timestamp is less than 7 days older than the current system time. -1 (lower case L): This specifies a minimum file size for the files to be listed. In essence, list ass files that are LARGER than the value given. -s: List all files which are smaller than the value given. So this is the maximum size a file can be to show up in the listing. You should use the time() functions to find the current epoch time. You can then add/subtract the appropriate number of second (ignoring leap years) to get a valid timestamp to compare to the stat() values. You should use the time() functions to find the current epoch time. You can then add/subtract the appropriate number of second (ignoring leap years) to get a valid timestamp to compare to the stat() values. directory_path: the last argument on the command line should be a directory specification. Use this parameter to point your code to a specific directory whose content you want to list. If this parameter is NOT there, the current working directory should be assumed (i.e...). You will be required to run your program against the /home/COIS/3380/lab3 directory on the loki.trentu.ca server. Your code however should work with any directory path. You can assume that any path over 4096 characters can be rejected by your code as too long. You should select a number of different values for the parameters. Larger than X but small than Y. Smaller than Z but created in the last 10 days. Things like that

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions