Second FAQ

for

Project 3 -- POSIX Files, Directories, and Permissions

Q. Can you please let me know as to how to find the last modification time done for a file or for a directory.I don't think its in the book.

A. As we have learned, the time information for a file on a UNIX system is kept in its i-node and the system calls for retrieving this information are stat, fstat, and lstat. Which of these you use for a particular file will depend on the syntax you want to use and whether or not you wish to follow symbolic links.

The stat and fstat system calls are covered in the Haviland book in Chapter 3.


Q. I have gone several websites and am unable to get the exact working of utime.h.I am still unable to get the modification time of a file.Please let me know this.

A. Note that utime.h is just a header file that defines the utimbuf structure. Probably what you are looking for is an explanation of the working of the utime system call.

I think the man pages for the utime system call are relatively clear. Note that they start with:


    utime - set file access and modification times

Note that this says set file access and modification times, whereas you say that you are unable to get the modification time. For getting the modification time, you want to use stat, fstat, or lstat.

If you need further help understanding the man pages for utime in order to set the file modification times, please let me know.