diff options
Diffstat (limited to 'Utility/Touch.hsc')
-rw-r--r-- | Utility/Touch.hsc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Utility/Touch.hsc b/Utility/Touch.hsc index 61276c523..ca4eb8475 100644 --- a/Utility/Touch.hsc +++ b/Utility/Touch.hsc @@ -13,11 +13,24 @@ module Utility.Touch ( touch ) where +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/time.h> + +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#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 @@ -28,16 +41,7 @@ touchBoth :: FilePath -> TimeSpec -> TimeSpec -> Bool -> IO () touch :: FilePath -> TimeSpec -> Bool -> IO () touch file mtime = touchBoth file mtime mtime -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <sys/time.h> - -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif - -#if (defined UTIME_OMIT && defined UTIME_NOW && defined AT_FDCWD && defined AT_SYMLINK_NOFOLLOW) +#ifdef use_utimensat at_fdcwd :: CInt at_fdcwd = #const AT_FDCWD |