diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-15 11:50:40 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-15 11:50:40 -0400 |
commit | 83a9bb624bcd7c5b4eee69bd91150d46c82146d8 (patch) | |
tree | 8a85a096d61ddd212869146affee7118ca17fd9d /Touch.hsc | |
parent | 7b0c6177ff9e0d0f2c23f798b14f1e49128f3589 (diff) |
fix error throwing
Diffstat (limited to 'Touch.hsc')
-rw-r--r-- | Touch.hsc | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -50,15 +50,17 @@ nowTime = TimeSpec 0 #const UTIME_NOW foreign import ccall "utimensat" c_utimensat :: CInt -> CString -> Ptr TimeSpec -> CInt -> IO CInt -{- Changes the access and/or modification times of a file. - Can follow symlinks, or not. -} -touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO Bool +{- Changes the access and/or modification times of an existing file. + Can follow symlinks, or not. Throws IO error on failure. -} +touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO () touchBoth file atime mtime follow = allocaArray 2 $ \ptr -> withCString file $ \f -> do pokeArray ptr [atime, mtime] r <- c_utimensat at_fdcwd f ptr flags - return (r == 0) + if (r /= 0) + then throwErrno "touchBoth" + else return () where at_fdcwd = #const AT_FDCWD at_symlink_nofollow = #const AT_SYMLINK_NOFOLLOW @@ -67,5 +69,5 @@ touchBoth file atime mtime follow = then 0 else at_symlink_nofollow -touch :: FilePath -> TimeSpec -> Bool -> IO Bool +touch :: FilePath -> TimeSpec -> Bool -> IO () touch file mtime follow = touchBoth file omitTime mtime follow |