how to use POSIX function utime?

Glynn Clements
Fri, 28 Mar 2003 01:39:13 +0000

David Roundy wrote:

> I'm trying to figure out how to use the POSIX function utime.  I'm pretty
> much stumped at the moment, largely because I can't figure out how to do
> anything useful with ClockTime variables.
> I can't see any way to make use of GHC.Posix.utime, as it gives a binding
> to the utime function, but the argument is of type Ptr (), and I can't see
> how to make this to a pointer to the contents of a pair of ClockTimes.
> I had thought that I could just write my own utime wrapper in C, but I'm
> still stumped on getting anything out of a ClockTime! The problem is that I
> would like my code to be portable, so I can't assume a ClockTime is a
> UInt32 (or that a time_t is a 32 bit int).  Any ideas how I can get around
> this?

AFAICT, the correct interface is Posix.setFileTimes:

	setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
	setFileTimes name atime mtime = do

EpochTime is the Haskell equivalent of C's time_t (integral number of
seconds since the epoch).

Glynn Clements <>