From 7c511f900d1fdd4bd4a8248385cf8f6edcd61df8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 29 Dec 2014 17:43:26 -0400 Subject: [PATCH] fix more warnings on BSD/OSX --- Utility/Touch.hsc | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Utility/Touch.hsc b/Utility/Touch.hsc index 61276c5230..ca4eb8475a 100644 --- a/Utility/Touch.hsc +++ b/Utility/Touch.hsc @@ -13,21 +13,6 @@ module Utility.Touch ( touch ) where -import Utility.FileSystemEncoding - -import Foreign -import Foreign.C -import Control.Monad (when) - -newtype TimeSpec = TimeSpec CTime - -{- Changes the access and modification times of an existing file. - Can follow symlinks, or not. Throws IO error on failure. -} -touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO () - -touch :: FilePath -> TimeSpec -> Bool -> IO () -touch file mtime = touchBoth file mtime mtime - #include #include #include @@ -38,6 +23,25 @@ touch file mtime = touchBoth file mtime mtime #endif #if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW) +#define use_utimensat 1 + +import Utility.FileSystemEncoding + +import Foreign +import Foreign.C +import Control.Monad (when) +#endif + +newtype TimeSpec = TimeSpec CTime + +{- Changes the access and modification times of an existing file. + Can follow symlinks, or not. Throws IO error on failure. -} +touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO () + +touch :: FilePath -> TimeSpec -> Bool -> IO () +touch file mtime = touchBoth file mtime mtime + +#ifdef use_utimensat at_fdcwd :: CInt at_fdcwd = #const AT_FDCWD