Skip to content

Commit

Permalink
Fix type error
Browse files Browse the repository at this point in the history
libraries/directory/System/Directory.hs:1550:10: error:
    • Couldn't match type ‘UTCTime’
                     with ‘time-1.6:Data.Time.Clock.UTC.NominalDiffTime’
      Expected type: Data.Time.Clock.POSIX.POSIXTime
        Actual type: UTCTime
    • In the second argument of ‘setFileTimes’, namely
        ‘(fromMaybe atimeOld atime')’
      In a stmt of a 'do' block:
        setFileTimes
          path' (fromMaybe atimeOld atime') (fromMaybe mtimeOld mtime')
      In the expression:
        do { (atimeOld, mtimeOld) <- fileTimesFromStatus
                                     <$> Posix.getFileStatus path';
             setFileTimes
               path' (fromMaybe atimeOld atime') (fromMaybe mtimeOld mtime') }
  • Loading branch information
bgamari committed Apr 17, 2016
1 parent 51c20ba commit 261147f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions System/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ import Data.Time ( UTCTime )
import Data.Time.Clock.POSIX
( posixSecondsToUTCTime
, utcTimeToPOSIXSeconds
#ifdef mingw32_HOST_OS
, POSIXTime
#endif
)

import GHC.IO.Exception ( IOErrorType(InappropriateType) )
Expand Down Expand Up @@ -1527,6 +1525,8 @@ setFileTimes path (atime, mtime) =
setTimes (utcTimeToPOSIXSeconds <$> atime, utcTimeToPOSIXSeconds <$> mtime)
where
path' = normalise path -- handle empty paths

setTimes :: (Maybe POSIXTime, Maybe POSIXTime) -> IO ()
#ifdef mingw32_HOST_OS
setTimes (atime', mtime') =
bracket (openFileHandle path' Win32.gENERIC_WRITE)
Expand All @@ -1543,16 +1543,18 @@ setFileTimes path (atime, mtime) =
throwErrnoPathIfMinus1_ "" path' $
c_utimensat c_AT_FDCWD path'' times 0
#else
setTimes (Just atime', Just mtime') = setFileTimes path' atime' mtime'
setTimes (Just atime', Just mtime') = setFileTimes' path' atime' mtime'
setTimes (atime', mtime') = do
(atimeOld, mtimeOld) <- fileTimesFromStatus <$> Posix.getFileStatus path'
setFileTimes path'
(fromMaybe atimeOld atime')
(fromMaybe mtimeOld mtime')
setFileTimes' path'
(fromMaybe (utcTimeToPOSIXSeconds atimeOld) atime')
(fromMaybe (utcTimeToPOSIXSeconds mtimeOld) mtime')

setFileTimes' :: FilePath -> POSIXTime -> POSIXTime -> IO ()
# if MIN_VERSION_unix(2, 7, 0)
setFileTimes = Posix.setFileTimesHiRes
setFileTimes' = Posix.setFileTimesHiRes
# else
setFileTimes pth atim mtime =
setFileTimes' pth atim mtime =
Posix.setFileTimes pth
(fromInteger (truncate atime))
(fromInteger (truncate mtime))
Expand Down

0 comments on commit 261147f

Please sign in to comment.