Skip to content

Commit 7bdf1da

Browse files
authored
Support time 1.11 and Win32 2.12 (#47)
* Allow time 1.11 * Support Win32 2.12 * Allow time 1.12
1 parent 3ae1124 commit 7bdf1da

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/System/PosixCompat/Files.hsc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import System.PosixCompat.Types
139139
import System.Win32.File hiding (getFileType)
140140
import System.Win32.HardLink (createHardLink)
141141
import System.Win32.Time (FILETIME(..), getFileTime, setFileTime)
142+
import System.Win32.Types (HANDLE)
142143

143144
import System.PosixCompat.Internal.Time (
144145
getClockTime, clockTimeToEpochTime
@@ -452,7 +453,7 @@ setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
452453
setFileTimes file atime mtime =
453454
bracket openFileHandle closeHandle $ \handle -> do
454455
(creationTime, _, _) <- getFileTime handle
455-
setFileTime
456+
setFileTimeCompat
456457
handle
457458
creationTime
458459
(epochTimeToFileTime atime)
@@ -472,6 +473,14 @@ setFileTimes file atime mtime =
472473
ll :: Int64
473474
ll = fromIntegral t * 10000000 + 116444736000000000
474475

476+
setFileTimeCompat :: HANDLE -> FILETIME -> FILETIME -> FILETIME -> IO ()
477+
setFileTimeCompat h crt acc wrt =
478+
#if MIN_VERSION_Win32(2, 12, 0)
479+
setFileTime h (Just crt) (Just acc) (Just wrt)
480+
#else
481+
setFileTime h crt acc wrt
482+
#endif
483+
475484
touchFile :: FilePath -> IO ()
476485
touchFile name =
477486
do t <- liftM clockTimeToEpochTime getClockTime

unix-compat.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Library
5757
else
5858
build-depends: directory == 1.1.*
5959
else
60-
build-depends: time >= 1.0 && < 1.10
60+
build-depends: time >= 1.0 && < 1.13
6161
build-depends: directory >= 1.2 && < 1.4
6262

6363
other-modules:

0 commit comments

Comments
 (0)