summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-15 11:50:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-15 11:50:40 -0400
commit83a9bb624bcd7c5b4eee69bd91150d46c82146d8 (patch)
tree8a85a096d61ddd212869146affee7118ca17fd9d
parent7b0c6177ff9e0d0f2c23f798b14f1e49128f3589 (diff)
fix error throwing
-rw-r--r--Command/Add.hs2
-rw-r--r--Touch.hsc12
2 files changed, 8 insertions, 6 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 09fff7cff..a577203bf 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -58,7 +58,7 @@ cleanup file key = do
-- touch the symlink to have the same mtime as the file it points to
s <- liftIO $ getFileStatus file
let mtime = modificationTime s
- _ <- liftIO $ touch file (TimeSpec mtime 0) False
+ liftIO $ touch file (TimeSpec mtime 0) False
Annex.queue "add" [Param "--"] file
return True
diff --git a/Touch.hsc b/Touch.hsc
index 34b34be51..689c58765 100644
--- a/Touch.hsc
+++ b/Touch.hsc
@@ -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