Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on OS X #47

Merged
merged 1 commit into from
Apr 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions System/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ import Data.Maybe
( catMaybes
#ifdef mingw32_HOST_OS
, maybeToList
#endif
#if !defined(mingw32_HOST_OS) && ! defined(HAVE_UTIMENSAT)
, fromMaybe
#endif
)

Expand All @@ -133,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 @@ -1524,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 @@ -1540,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