Homework 6:

Short Description:

Write a program that summarizes the files in a directory tree.

This assignment is worth 15 points.

Goals

When you finish this homework, you should

Formal Description

Write a program that, given a directory as the first command line argument, summarizes the files in the directory tree for which that directory is the root.

Begin by opening the directory and examining each file contained therein. The files . and .. should not be counted. For every directory listed, recursively apply your program. You can do this either with the run time stack or using a queue.

For each file encountered, record the owner of the file and the type of the file. When you have traversed the entire tree, print a summary as follows

	user1	user2	user3	...
- 	xxxx	xxxx	xxxx	...
d 	xxxx	xxxx	xxxx	...
l 	xxxx	xxxx	xxxx	...
p 	xxxx	xxxx	xxxx	...
s 	xxxx	xxxx	xxxx	...
c 	xxxx	xxxx	xxxx	...
b 	xxxx	xxxx	xxxx	...
where xxxx is the number of each type of file encountered by type and user. The rows are labeled with the "traditional" letters used by ls for each file type. Columns are labeled by the user name. Entries are separated by tabs.

For example, if the directory foo holds three regular files, with no subidrectories and all files are owned by a single user bar, the report should be

	bar
- 	   3
d 	   0
l 	   0
p 	   0
s 	   0
c 	   0
b 	   0

Be careful not to follow symbolic links to directories or you might get into an infinite loop.

I would use either a vector or better yet a map to store my data.

Submission

Please email you code to dbennett@edinboro.edu by the due date.