1
answer
1
watching
314
views

The goal of this project is to practice on basic library functions for reading directories in Linux. You will implement a program that lists all the files in a given directory.

  1. Your program should take two possible command line arguments. For example “./myls -a ~/Document”

  2. The first argument is an option started with a dash “-”. Legitimate options are “-a” and “-l”.

  3. If “-a” is giving, you need to list all files including hidden file start with “.”.

  4. If “-l” is giving, you need to list one file per line with detailed information (file type, permission, link number, user, group, size, modification time, and file name). The format should be the same as the real “ls -l”.

  5. If no dash option is given, you only list file names with hidden file excluded.

  6. The second argument is a path (relative or absolute) to a directory. If present, list the files in the specified directory. If no second argument is given, list the files in current directory.

  7. use getpwuid(), getgrgid(), ctime() to decode the file type, permission, user name, group name, modification time in the “stat” structure.

  8. You can write your own sorting function or research on how to use qsort().

program must be in C

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in

Related questions

Weekly leaderboard

Start filling in the gaps now
Log in