
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? The only idea I have at the moment is to define a MyClockTime which is always a UInt64 and then do in my C wrapper I could cast back and forth from time_t to an int64 type. Ugh. -- David Roundy http://www.abridgegame.org

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

On Fri, Mar 28, 2003 at 01:39:13AM +0000, Glynn Clements wrote:
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).
Thanks for the pointer! It seems I had totally missed the documentation on hslibs, and was thus looking in entirely the wrong place. (Feeling somewhat foolish...) -- David Roundy http://civet.berkeley.edu/droundy/
participants (2)
-
David Roundy
-
Glynn Clements