[Finally done with times John Goerzen **20071024092855] { hunk ./en/ch20-systems.xml 408 - + + + File Modification Times + + Many programs need to find out when particular files were last + modified. Programs such as ls or graphical file + managers typically display the modification time of files. + The System.Directory module contains a + cross-platform getModificationTime function. It + takes a filename and returns a &ClockTime; representing the time the + file was last modified. For instance: + + &modtime.ghci:all; + + POSIX platforms maintain not just a modification time (known as + mtime), but also the time of last read or write access (atime) and + the time of last status change (ctime). Since this information is + POSIX-specific, the cross-platform + System.Directory module does not provide access to + it. Instead, you will need to use functions in + System.Posix.Files. Here is an example function + to do that: + + &posixtime.hs:all; + + Notice that call to getFileStatus. That call maps + directly to the C function stat(). Its return + value stores a vast assortment of information, including file + type, permissions, owner, group, and the three time values we're + interested in. System.Posix.Files provides + various functions, such as accessTime, that + extract the information we're interested out of the opaque + FileStatus type returned by + getFileStatus. + + + System.Posix.Files also provides a + setFileTimes function to set the atime and mtime + for a file.It is not normally possible to set the + ctime on POSIX systems. + hunk ./en/ch20-systems.xml 450 - }