[commit: packages/Cabal] ghc-head: Fix 'getModTime' with base < 4.5. (0b4ffe3)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:23:28 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=0b4ffe3aa3bcf935a439ae5dc8f6dc4059eb548c

>---------------------------------------------------------------

commit 0b4ffe3aa3bcf935a439ae5dc8f6dc4059eb548c
Author: Mikhail Glushenkov <the.dead.shall.rise at gmail.com>
Date:   Wed May 1 17:01:50 2013 +0200

    Fix 'getModTime' with base < 4.5.


>---------------------------------------------------------------

0b4ffe3aa3bcf935a439ae5dc8f6dc4059eb548c
 cabal-install/Distribution/Compat/Time.hs |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/cabal-install/Distribution/Compat/Time.hs b/cabal-install/Distribution/Compat/Time.hs
index 6e6171a..8ea8b71 100644
--- a/cabal-install/Distribution/Compat/Time.hs
+++ b/cabal-install/Distribution/Compat/Time.hs
@@ -37,7 +37,11 @@ index_WIN32_FILE_ATTRIBUTE_DATA_ftLastWriteTime_dwLowDateTime = 20
 
 #else
 
+#if MIN_VERSION_base(4,5,0)
 import Foreign.C.Types    (CTime(..))
+#else
+import Foreign.C.Types    (CTime)
+#endif
 import System.Posix.Files (getFileStatus, modificationTime)
 
 #endif
@@ -74,9 +78,15 @@ getModTime path = withCString path $ \file ->
 
 -- Directly against the unix library.
 getModTime path = do
-    (CTime i) <- fmap modificationTime $ getFileStatus path
-    -- CTime is Int32 in base < 4.6, but Int64 in base >= 4.6.
+    -- CTime is Int32 in base 4.5, Int64 in base >= 4.6, and an abstract type in
+    -- base < 4.5.
+    t <- fmap modificationTime $ getFileStatus path
+#if MIN_VERSION_base(4,5,0)
+    let CTime i = t
     return (fromIntegral i)
+#else
+    return (read . show $ t)
+#endif
 #endif
 
 -- | Return age of given file in days.





More information about the ghc-commits mailing list