Due: Thursday 11/04 8:00 am
GitHub Submission Link: git@github.com:mks65/12_dirinfo.git
New and improved addition:
- Your program should handle user input as follows:
- If a command line argument is entered, use that as the directory to scan.
- If not, the program should ask the user to enter a directory to scan.
- In either case, don’t assume your user knows what they are doing, if an invalid directory is entered, take reasonable action (ahem
errno
cough cough)
Write a program that will gather various information about a directory, specifically:
- For the current directory (
"./"
) - list all the files in the directory
- specify which files are directories (if any)
- show the total size of all the regular files the directory
- note that you do not have to recursively go through any subdirectories to find their size for this part (unless you want to, but that is not a simple task)
- Possible enhancements:
- Recursively list the files in any subdirectories, update the total to include the total size of subdirectories
- Print out the size in a more readable format (like using KB, MB, GB for -byte prefixes)
- Make it look more like
$ ls -l
Below is sample output, yours may differ, but as long as it presents the information requested above you will receive full credit.
$ ./a.out
Statistics for directory: .
Total Diectory Size: 17766 Bytes
Directories:
.
..
dir
structRW
Regular files:
a.out
error.log
filelist
files.c
read.c
ReadTest
redirect.c
redirect.c~
redirect_full.c
redirect_full.c~
redirTest
statfiles.c
statfiles.c~
write.c
WriteTest