summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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