diff --git a/src/System/PosixCompat/Files.hsc b/src/System/PosixCompat/Files.hsc index 0205a21..95bf23a 100644 --- a/src/System/PosixCompat/Files.hsc +++ b/src/System/PosixCompat/Files.hsc @@ -139,6 +139,7 @@ import System.PosixCompat.Types import System.Win32.File hiding (getFileType) import System.Win32.HardLink (createHardLink) import System.Win32.Time (FILETIME(..), getFileTime, setFileTime) +import System.Win32.Types (HANDLE) import System.PosixCompat.Internal.Time ( getClockTime, clockTimeToEpochTime @@ -452,7 +453,7 @@ setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO () setFileTimes file atime mtime = bracket openFileHandle closeHandle $ \handle -> do (creationTime, _, _) <- getFileTime handle - setFileTime + setFileTimeCompat handle creationTime (epochTimeToFileTime atime) @@ -472,6 +473,14 @@ setFileTimes file atime mtime = ll :: Int64 ll = fromIntegral t * 10000000 + 116444736000000000 +setFileTimeCompat :: HANDLE -> FILETIME -> FILETIME -> FILETIME -> IO () +setFileTimeCompat h crt acc wrt = +#if MIN_VERSION_Win32(2, 12, 0) + setFileTime h (Just crt) (Just acc) (Just wrt) +#else + setFileTime h crt acc wrt +#endif + touchFile :: FilePath -> IO () touchFile name = do t <- liftM clockTimeToEpochTime getClockTime diff --git a/unix-compat.cabal b/unix-compat.cabal index 7c59b9f..941ed37 100644 --- a/unix-compat.cabal +++ b/unix-compat.cabal @@ -57,7 +57,7 @@ Library else build-depends: directory == 1.1.* else - build-depends: time >= 1.0 && < 1.10 + build-depends: time >= 1.0 && < 1.13 build-depends: directory >= 1.2 && < 1.4 other-modules: