Permalink
Browse files

Support directory 1.2

The type of getModificationTime has changed, leading to some CPP
  • Loading branch information...
1 parent 5387781 commit f91df6fec9b9a510fabd1e57da32ba9f1799ad2a @hsenag hsenag committed Sep 12, 2012
Showing with 16 additions and 1 deletion.
  1. +7 −0 Codec/Archive/Zip.hs
  2. +9 −1 zip-archive.cabal
@@ -55,6 +55,9 @@ module Codec.Archive.Zip
) where
import System.Time ( toUTCTime, addToClockTime, CalendarTime (..), ClockTime (..), TimeDiff (..) )
+#ifndef _DIRECTORY_1_1
+import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds )
+#endif
import Data.Bits ( shiftL, shiftR, (.&.) )
import Data.Binary
import Data.Binary.Get
@@ -199,7 +202,11 @@ readEntry opts path = do
contents <- if isDir
then return B.empty
else B.readFile path
+#ifdef _DIRECTORY_1_1
(TOD modEpochTime _) <- getModificationTime path
+#else
+ modEpochTime <- liftM (floor . utcTimeToPOSIXSeconds) $ getModificationTime path
+#endif
let entry = toEntry path' modEpochTime contents
when (OptVerbose `elem` opts) $ do
let compmethod = case eCompressionMethod entry of
View
@@ -20,13 +20,21 @@ flag splitBase
flag executable
Description: Build the Zip executable.
Default: False
+flag directory11
+ Description: Use version 1.1.x or earlier of the directory package
+ Default: False
Library
if flag(splitBase)
Build-depends: base >= 3 && < 5, pretty, containers
else
Build-depends: base < 3
- Build-depends: binary, zlib, filepath, directory, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1
+ if flag(directory11)
+ Build-depends: directory < 1.2
+ cpp-options: -D_DIRECTORY_1_1
+ else
+ Build-depends: directory >= 1.2, time
+ Build-depends: binary, zlib, filepath, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1
Exposed-modules: Codec.Archive.Zip
Hs-Source-Dirs: .
Ghc-Options: -Wall

0 comments on commit f91df6f

Please sign in to comment.