CSc 3320 System-Level Programming
Fall 2000
Homework #6
Due: 11 December 2000 (Monday)

IMPORTANT NOTE: Upon reconsideration, I have decided to have only 5 assignments. So, this one is the extra credit one!

Write a C program, called myls, to display file names and their date and time stamps. The program should have a command line parameter which denotes a file specification (which may be an exact file name or a suffix of a file name such as sql or c). The output should look as follows:

% myls sql
  p1.sql         10-AUG-1996 10:00 AM
  prog1.sql      16-JAN-1995 12:20 PM
  p.sql          20-DEC-1995 11:15 AM
D ch6sql         20-DEC-1995 11:15 AM
  qq.sql         11-SEP-1991 03:25 PM
% 
Remarks:
  1. The names of the matching files must be left justified and the dates and times must be formatted as shown above.
  2. If the file is a directory file, the letter D should appear to the left of the file name.
  3. If the file specification is missing, the command should list all the files in the current default directory.
  4. You will need to consult time.h functions (describe very well in Dr. King's book); You will also need to learn several system calls (opendir, readdir, closedir,..) to manipulate directory files. These are described in the monitor.c program in the transparencies (Page 36). Please do not use the monitor.c program in the book; There is a slight portability problem with the code in the book for monitor.c; I had rewritten the function on Page 36 of the transparencies.