zip-archive 0.1.3.2 → 0.1.3.3
raw patch · 2 files changed
+44/−3 lines, 2 filesdep ~binary
Dependency ranges changed: binary
Files
- Codec/Archive/Zip.hs +42/−1
- zip-archive.cabal +2/−2
Codec/Archive/Zip.hs view
@@ -75,7 +75,9 @@ import System.IO ( stderr, hPutStrLn ) import qualified Data.Digest.CRC32 as CRC32 import qualified Data.Map as M+#if MIN_VERSION_binary(0, 6, 0) import Control.Applicative+#endif #ifndef _WINDOWS import System.Posix.Files ( setFileTimes ) #endif@@ -89,6 +91,18 @@ -- from zlib import qualified Codec.Compression.Zlib.Raw as Zlib +#if !MIN_VERSION_binary(0, 6, 0)+manySig :: Word32 -> Get a -> Get [a]+manySig sig p = do+ sig' <- lookAhead getWord32le+ if sig == sig'+ then do+ r <- p+ rs <- manySig sig p+ return $ r : rs+ else return []+#endif+ ------------------------------------------------------------------------ -- | Structured representation of a zip archive, including directory@@ -411,9 +425,15 @@ getArchive :: Get Archive getArchive = do+#if MIN_VERSION_binary(0, 6, 0) locals <- many getLocalFile files <- many (getFileHeader (M.fromList locals)) digSig <- Just `fmap` getDigitalSignature <|> return Nothing+#else+ locals <- manySig 0x04034b50 getLocalFile+ files <- manySig 0x02014b50 (getFileHeader (M.fromList locals))+ digSig <- lookAheadM getDigitalSignature+#endif endSig <- getWord32le unless (endSig == 0x06054b50) $ fail "Did not find end of central directory signature"@@ -520,11 +540,21 @@ return (fromIntegral offset, compressedData) getWordsTilSig :: Word32 -> Get [Word8]-getWordsTilSig sig =+getWordsTilSig sig = do+#if MIN_VERSION_binary(0, 6, 0) (getWord32le >>= ensure (== sig) >> return []) <|> do w <- getWord8 ws <- getWordsTilSig sig return (w:ws)+#else+ sig' <- lookAhead getWord32le+ if sig == sig'+ then skip 4 >> return []+ else do+ w <- getWord8+ ws <- getWordsTilSig sig+ return (w:ws)+#endif putLocalFile :: Entry -> Put putLocalFile f = do@@ -656,11 +686,22 @@ -- > size of data 2 bytes -- > signature data (variable size) +#if MIN_VERSION_binary(0, 6, 0) getDigitalSignature :: Get B.ByteString getDigitalSignature = do getWord32le >>= ensure (== 0x05054b50) sigSize <- getWord16le getLazyByteString (toEnum $ fromEnum sigSize)+#else+getDigitalSignature :: Get (Maybe B.ByteString)+getDigitalSignature = do+ hdrSig <- getWord32le+ if hdrSig /= 0x05054b50+ then return Nothing+ else do+ sigSize <- getWord16le+ getLazyByteString (toEnum $ fromEnum sigSize) >>= return . Just+#endif putDigitalSignature :: Maybe B.ByteString -> Put putDigitalSignature Nothing = return ()
zip-archive.cabal view
@@ -1,5 +1,5 @@ Name: zip-archive-Version: 0.1.3.2+Version: 0.1.3.3 Cabal-Version: >= 1.10 Build-type: Simple Synopsis: Library for creating and modifying zip archives.@@ -29,7 +29,7 @@ Build-depends: base >= 3 && < 5, pretty, containers else Build-depends: base < 3- Build-depends: binary >= 0.6, zlib, filepath, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1, directory, time+ Build-depends: binary >= 0.5, zlib, filepath, bytestring >= 0.9.0, array, mtl, utf8-string >= 0.3.1, old-time, digest >= 0.0.0.1, directory, time Exposed-modules: Codec.Archive.Zip Default-Language: Haskell98 Hs-Source-Dirs: .