summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-16 13:48:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-16 13:48:04 -0400
commit0f8edc99ee76a80c948bdedc42730e7679a822a0 (patch)
tree24a4feaed2ce1eb57a5398102c7d4555631ec5d8
parent8ad321312af7c4384b86ab6c70aea2afc8f86fd9 (diff)
parent35cbd107d5107eb96f52860098b1036c73281715 (diff)
Merge branch 'master' into reorg
Conflicts: debian/changelog
-rw-r--r--Touch.hsc37
-rw-r--r--debian/changelog1
2 files changed, 26 insertions, 12 deletions
diff --git a/Touch.hsc b/Touch.hsc
index f0c4debb3..456175182 100644
--- a/Touch.hsc
+++ b/Touch.hsc
@@ -28,6 +28,25 @@ import Foreign.C
data TimeSpec = TimeSpec CTime CLong
+touch :: FilePath -> TimeSpec -> Bool -> IO ()
+touch file mtime follow = touchBoth file omitTime mtime follow
+
+touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO ()
+
+omitTime :: TimeSpec
+nowTime :: TimeSpec
+
+#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW)
+
+at_fdcwd :: CInt
+at_fdcwd = #const AT_FDCWD
+
+at_symlink_nofollow :: CInt
+at_symlink_nofollow = #const AT_SYMLINK_NOFOLLOW
+
+omitTime = TimeSpec 0 #const UTIME_OMIT
+nowTime = TimeSpec 0 #const UTIME_NOW
+
instance Storable TimeSpec where
-- use the larger alignment of the two types in the struct
alignment _ = max sec_alignment nsec_alignment
@@ -43,12 +62,6 @@ instance Storable TimeSpec where
#{poke struct timespec, tv_sec} ptr sec
#{poke struct timespec, tv_nsec} ptr nsec
-{- special timespecs -}
-omitTime :: TimeSpec
-omitTime = TimeSpec 0 #const UTIME_OMIT
-nowTime :: TimeSpec
-nowTime = TimeSpec 0 #const UTIME_NOW
-
{- While its interface is beastly, utimensat is in recent
POSIX standards, unlike futimes. -}
foreign import ccall "utimensat"
@@ -56,7 +69,6 @@ foreign import ccall "utimensat"
{- 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
@@ -66,12 +78,13 @@ touchBoth file atime mtime follow =
then throwErrno "touchBoth"
else return ()
where
- at_fdcwd = #const AT_FDCWD
- at_symlink_nofollow = #const AT_SYMLINK_NOFOLLOW
-
flags = if follow
then 0
else at_symlink_nofollow
-touch :: FilePath -> TimeSpec -> Bool -> IO ()
-touch file mtime follow = touchBoth file omitTime mtime follow
+#else
+#warning "utimensat not available; building without symlink timestamp preservation support"
+omitTime = TimeSpec 0 (-1)
+nowTime = TimeSpec 0 (-2)
+touchBoth _ _ _ _ = return ()
+#endif
diff --git a/debian/changelog b/debian/changelog
index 68afb1293..e9fdceee6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,6 +18,7 @@ git-annex (0.20110316) UNRELEASED; urgency=low
content are made to have the same mtime as the original file.
While git does not preserve that information, this allows a tool
like metastore to be used with annexed files.
+ (Currently this is only done on systems supporting POSIX 200809.)
-- Joey Hess <joeyh@debian.org> Sun, 13 Mar 2011 14:25:17 -0400