Back
CS 456 Home

Assignment h3: Filetypes

Due Date: Mar 27 at 8AM EDT

In this assignment, you will be writing a program that takes a file, and 
depending on whether it's a regular file, a directory, or something else, you
will have it do something different.

In the h3 folder you will see the source code filetype.c, which has comments 
and not much else right now. You are going to have the program do the following:

If it is a regular file:
- print the following values:
	- file name
	- device_id
	- inode
	- permissions (in octal)
	- size

If it is a directory:
- open the directory, print the contents that are NOT hidden files
- print the count of the total number of files as well as the number of hidden 
  files

If it is anything else:
- just print the name of the file along with it's filetype (in octal)

There's some example code in the mar18 directory of the In-class code you can 
look at that should help you out. I ask that you not depend on Generative AI 
(like ChatGPT, etc) to do this assignment. You should be able to do this 
assignment based on the examples given in the book and in the In-class code.

To pick up this assignment, copy the h1 folder into your cs456 directory by running: 
		     cp -R /home/cs456/h3/ ~/cs456/
		OR:  hw_get.py cs456 h3

Then use a text editor (like vi, nano, emacs) to open it and make the necessary 
edits to accomplish these objectives.

Once finished, leave it in that directory. I will run a script to collect the 
files when the due date approaches. 

Final note: Do as well as you can with this assignment, as there may be a 
possible part 2 to this assignment involving things from future chapters.