Ticket #7473 (new bug)
getModificationTime gives only second-level resolution
| Reported by: | duncan | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.8.1 |
| Component: | libraries/directory | Version: | 7.6.1 |
| Keywords: | Cc: | the.dead.shall.rise@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
The System.Directory.getModificationTime function only returns time with second-level granularity. This is no good for applications like ghc --make where we need to compare file timestamps.
The fix should be simple, here's a patch (compiles but not tested) that should fix it for Unix, for Windows we will need a different fix, probably using the Win32 API directly, rather than the mingw C api.
diff --git a/System/Directory.hs b/System/Directory.hs index cfe7cd9..f27bfc4 100644 --- a/System/Directory.hs +++ b/System/Directory.hs @@ -995,14 +995,14 @@ The operation may fail with: getModificationTime :: FilePath -> IO UTCTime getModificationTime name = do #ifdef mingw32_HOST_OS - -- ToDo: use Win32 API + -- ToDo: use Win32 API so we can get sub-second resolution withFileStatus "getModificationTime" name $ \ st -> do modificationTime st #else stat <- Posix.getFileStatus name - let mod_time :: Posix.EpochTime - mod_time = Posix.modificationTime stat - return $ posixSecondsToUTCTime $ realToFrac mod_time + let mod_time :: POSIXTime + mod_time = Posix.modificationTimeHiRes stat + return $! posixSecondsToUTCTime mod_time #endif #endif /* __GLASGOW_HASKELL__ */
Change History
Note: See
TracTickets for help on using
tickets.
