zip-archive 0.1.1.3 → 0.1.1.4
raw patch · 3 files changed
+32/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Codec/Archive/Zip.hs +27/−3
- Zip.hs +1/−1
- zip-archive.cabal +4/−4
Codec/Archive/Zip.hs view
@@ -65,7 +65,7 @@ import System.FilePath import System.Directory ( doesDirectoryExist, getDirectoryContents, createDirectoryIfMissing ) import qualified Control.Monad.State as S-import Control.Monad ( when, unless, zipWithM )+import Control.Monad ( when, unless, zipWithM, liftM ) import System.Directory ( getModificationTime ) import System.IO ( stderr, hPutStrLn ) import qualified Data.Digest.CRC32 as CRC32@@ -468,6 +468,12 @@ -- -- > file name (variable size) -- > extra field (variable size)+--+-- Note that if bit 3 of the general purpose bit flag is set, then the+-- compressed size will be 0 and the size will be stored instead in a+-- data descriptor record AFTER the file contents. The record normally+-- begins with the signature 0x08074b50, then 4 bytes crc-32, 4 bytes+-- compressed size, 4 bytes uncompressed size. getLocalFile :: Get (Maybe (Word32, B.ByteString)) getLocalFile = do@@ -478,7 +484,7 @@ offset <- bytesRead skip 4 -- signature skip 2 -- version- skip 2 -- general purpose bit flag+ bitflag <- getWord16le skip 2 -- compressionMethod skip 2 -- last mod file time skip 2 -- last mod file date@@ -491,7 +497,25 @@ extraFieldLength <- getWord16le skip (fromIntegral fileNameLength) -- filename skip (fromIntegral extraFieldLength) -- extra field- compressedData <- getLazyByteString (fromIntegral compressedSize)+ compressedData <- if bitflag .&. 0O10 == 0+ then getLazyByteString (fromIntegral compressedSize)+ else -- If bit 3 of general purpose bit flag is set,+ -- then we need to read until we get to the+ -- data descriptor record. We assume that the+ -- record has signature 0x08074b50; this is not required+ -- by the specification but is common.+ do raw <- many $ do+ s <- lookAhead getWord32le+ if s == 0x08074b50+ then return Nothing+ else liftM Just getWord8+ skip 4 -- signature+ skip 4 -- crc32+ cs <- getWord32le -- compressed size+ skip 4 -- uncompressed size+ if fromIntegral cs == length raw+ then return $ B.pack raw+ else fail "Content size mismatch in data descriptor record" return $ Just (fromIntegral offset, compressedData) putLocalFile :: Entry -> Put
Zip.hs view
@@ -45,7 +45,7 @@ progname <- getProgName let header = "Usage: " ++ progname ++ " [OPTION...] archive files..." (opts, args) <- case getOpt Permute options argv of- (o, _, _) | Version `elem` o -> putStrLn "version 0.1.1.3" >> exitWith ExitSuccess+ (o, _, _) | Version `elem` o -> putStrLn "version 0.1.1.4" >> exitWith ExitSuccess (o, _, _) | Help `elem` o -> error $ usageInfo header options (o, (a:as), []) -> return (o, a:as) (_, _, errs) -> error $ concat errs ++ "\n" ++ usageInfo header options
zip-archive.cabal view
@@ -1,5 +1,5 @@ Name: zip-archive-Version: 0.1.1.3+Version: 0.1.1.4 Cabal-version: >= 1.2 Build-type: Simple Synopsis: Library for creating and modifying zip archives.@@ -22,13 +22,13 @@ Library if flag(splitBase)- Build-depends: base >= 3, pretty, containers+ 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 Exposed-modules: Codec.Archive.Zip Hs-Source-Dirs: .- Ghc-Options: -Wall -O2+ Ghc-Options: -Wall Extensions: CPP if os(windows) cpp-options: -D_WINDOWS@@ -41,4 +41,4 @@ else Buildable: False Main-is: Zip.hs- Ghc-Options: -Wall -O2+ Ghc-Options: -Wall