fix more warnings on BSD/OSX

This commit is contained in:
Joey Hess 2014-12-29 17:43:26 -04:00
parent 66cdc4d612
commit 7c511f900d

View file

@ -13,21 +13,6 @@ module Utility.Touch (
touch touch
) where ) 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 <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -38,6 +23,25 @@ touch file mtime = touchBoth file mtime mtime
#endif #endif
#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW) #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 :: CInt
at_fdcwd = #const AT_FDCWD at_fdcwd = #const AT_FDCWD