zip 0.1.3 → 0.1.4
raw patch · 5 files changed
+101/−38 lines, 5 filesdep ~QuickCheckdep ~basedep ~conduit
Dependency ranges changed: QuickCheck, base, conduit, conduit-extra, criterion, hspec, mtl, path, path-io, plan-b, resourcet, zip
Files
- CHANGELOG.md +13/−0
- Codec/Archive/Zip.hs +46/−0
- Codec/Archive/Zip/Type.hs +7/−4
- README.md +1/−0
- zip.cabal +34/−34
CHANGELOG.md view
@@ -1,3 +1,16 @@+## Zip 0.1.4++* Added several simple code examples in `Codec.Archive.Zip`.++* Derived `Typeable`, `Data`, `Generic` for `EntrySelector`.++* Derived `Typeable` for `EntryDescription`.++* Derived `Show`, `Ord`, `Bounded`, `Data`, and `Typeable` for+ `CompressionMethod`.++* Derived `Read`, `Ord`, `Typeable`, and `Data` for `ArchiveDescription`.+ ## Zip 0.1.3 * Improved speed of detection of invalid archives.
Codec/Archive/Zip.hs view
@@ -31,6 +31,50 @@ -- actions are performed automatically when you leave the realm of -- 'ZipArchive' monad. If, however, you ever need to force update, 'commit' -- function is your friend. There are even “undo” functions, by the way.+--+-- An example of a program that prints list of archive entries:+--+-- > import Codec.Archive.Zip+-- > import Path.IO (resolveFile')+-- > import System.Environment (getArgs)+-- > import qualified Data.Map as M+-- >+-- > main :: IO ()+-- > main = do+-- > [fp] <- getArgs+-- > path <- resolveFile' fp+-- > entries <- withArchive path (M.keys <$> getEntries)+-- > mapM_ print entries+--+-- Create a Zip archive with a Hello World file:+--+-- > import Codec.Archive.Zip+-- > import Path (parseRelFile)+-- > import Path.IO (resolveFile')+-- > import System.Environment (getArgs)+-- >+-- > main :: IO ()+-- > main = do+-- > [fp] <- getArgs+-- > path <- resolveFile' fp+-- > s <- parseRelFile "hello-world.txt" >>= mkEntrySelector+-- > createArchive path (addEntry Store "Hello, World!" s)+--+-- Extract contents of specific file and print it:+--+-- > import Codec.Archive.Zip+-- > import Path (parseRelFile)+-- > import Path.IO (resolveFile')+-- > import System.Environment (getArgs)+-- > import qualified Data.ByteString.Char8 as B+-- >+-- > main :: IO ()+-- > main = do+-- > [fp,f] <- getArgs+-- > path <- resolveFile' fp+-- > s <- parseRelFile f >>= mkEntrySelector+-- > bs <- withArchive path (getEntry s)+-- > B.putStrLn bs {-# LANGUAGE GeneralizedNewtypeDeriving #-} @@ -249,6 +293,8 @@ -- | Get entry source. -- -- Throws: 'EntryDoesNotExist'.+--+-- @since 0.1.3 getEntrySource :: EntrySelector
Codec/Archive/Zip/Type.hs view
@@ -12,6 +12,7 @@ -- that module instead. {-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE DeriveGeneric #-} module Codec.Archive.Zip.Type ( -- * Entry selector@@ -34,6 +35,7 @@ import Control.Monad.Catch (MonadThrow (..)) import Data.ByteString (ByteString) import Data.CaseInsensitive (CI)+import Data.Data (Data) import Data.List.NonEmpty (NonEmpty) import Data.Map (Map) import Data.Maybe (mapMaybe, fromJust)@@ -42,6 +44,7 @@ import Data.Typeable (Typeable) import Data.Version (Version) import Data.Word (Word16, Word32)+import GHC.Generics (Generic) import Numeric.Natural import Path import qualified Data.ByteString as B@@ -75,7 +78,7 @@ newtype EntrySelector = EntrySelector { unES :: NonEmpty (CI String) -- ^ Path pieces of relative path inside archive- } deriving (Eq, Ord)+ } deriving (Eq, Ord, Typeable, Data, Generic) instance Show EntrySelector where show = show . unEntrySelector@@ -162,7 +165,7 @@ , edOffset :: Natural -- ^ Absolute offset of local file header , edComment :: Maybe Text -- ^ Entry comment , edExtraField :: Map Word16 ByteString -- ^ All extra fields found- } deriving Eq+ } deriving (Eq, Typeable) -- | Supported compression methods. @@ -170,7 +173,7 @@ = Store -- ^ Store file uncompressed | Deflate -- ^ Deflate | BZip2 -- ^ Compressed using BZip2 algorithm- deriving (Eq, Enum, Read, Show)+ deriving (Show, Read, Eq, Ord, Enum, Bounded, Data, Typeable) ---------------------------------------------------------------------------- -- Archive description@@ -181,7 +184,7 @@ { adComment :: Maybe Text -- ^ Comment of entire archive , adCDOffset :: Natural -- ^ Absolute offset of start of central directory , adCDSize :: Natural -- ^ Size of central directory record- } deriving (Eq, Show)+ } deriving (Show, Read, Eq, Ord, Typeable, Data) ---------------------------------------------------------------------------- -- Exceptions
README.md view
@@ -3,6 +3,7 @@ [](http://opensource.org/licenses/BSD-3-Clause) [](https://hackage.haskell.org/package/zip) [](http://stackage.org/nightly/package/zip)+[](http://stackage.org/lts/package/zip) [](https://travis-ci.org/mrkkrp/zip) [](https://coveralls.io/github/mrkkrp/zip?branch=master)
zip.cabal view
@@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE. name: zip-version: 0.1.3+version: 0.1.4 cabal-version: >= 1.10 license: BSD3 license-file: LICENSE.md@@ -43,7 +43,7 @@ synopsis: Operations on zip archives build-type: Simple description: Operations on zip archives.-extra-source-files: CHANGELOG.md+extra-doc-files: CHANGELOG.md , README.md flag dev@@ -52,25 +52,25 @@ default: False library- build-depends: base >= 4.8 && < 5- , bytestring >= 0.9 && < 0.11- , bzlib-conduit >= 0.2 && < 0.3+ build-depends: base >= 4.8 && < 5.0+ , bytestring >= 0.9 && < 0.11+ , bzlib-conduit >= 0.2 && < 0.3 , case-insensitive >= 1.2.0.2 && < 1.3- , cereal >= 0.3 && < 0.6- , conduit >= 1.1 && < 2- , conduit-extra >= 1.1 && < 2+ , cereal >= 0.3 && < 0.6+ , conduit >= 1.1 && < 2.0+ , conduit-extra >= 1.1 && < 2.0 , containers >= 0.5.6.2 && < 0.6 , digest < 0.1- , exceptions >= 0.6 && < 0.9- , filepath >= 1.2 && < 1.5- , mtl >= 2.0 && < 3- , path >= 0.5 && < 6- , path-io >= 1.0.1 && < 2- , plan-b >= 0.2.0- , resourcet >= 1.0 && < 2- , text >= 0.2 && < 1.3- , time >= 1.4 && < 1.7- , transformers >= 0.4 && < 0.6+ , exceptions >= 0.6 && < 0.9+ , filepath >= 1.2 && < 1.5+ , mtl >= 2.0 && < 3.0+ , path >= 0.5 && < 0.6+ , path-io >= 1.0.1 && < 2.0+ , plan-b >= 0.2 && < 0.3+ , resourcet >= 1.0 && < 2.0+ , text >= 0.2 && < 1.3+ , time >= 1.4 && < 1.7+ , transformers >= 0.4 && < 0.6 if !impl(ghc >= 8.0) build-depends: semigroups >= 0.16 default-extensions: RecordWildCards@@ -93,20 +93,20 @@ ghc-options: -Wall -Werror else ghc-options: -O2 -Wall- build-depends: base >= 4.8 && < 5- , bytestring >= 0.9 && < 0.11- , conduit >= 1.1 && < 2+ build-depends: base >= 4.8 && < 5.0+ , bytestring >= 0.9 && < 0.11+ , conduit >= 1.1 && < 2.0 , containers >= 0.5.6.2 && < 0.6- , exceptions >= 0.6 && < 0.9- , filepath >= 1.2 && < 1.5- , QuickCheck >= 2.4 && < 3- , hspec >= 2.0 && < 3- , path >= 0.5 && < 6- , path-io >= 1.0.1 && < 2- , text >= 0.2 && < 1.3- , time >= 1.4 && < 1.7- , transformers >= 0.4 && < 0.6- , zip >= 0.1.3+ , exceptions >= 0.6 && < 0.9+ , filepath >= 1.2 && < 1.5+ , QuickCheck >= 2.4 && < 3.0+ , hspec >= 2.0 && < 3.0+ , path >= 0.5 && < 6.0+ , path-io >= 1.0.1 && < 2.0+ , text >= 0.2 && < 1.3+ , time >= 1.4 && < 1.7+ , transformers >= 0.4 && < 0.6+ , zip >= 0.1.4 default-language: Haskell2010 benchmark bench@@ -117,9 +117,9 @@ ghc-options: -O2 -Wall -Werror else ghc-options: -O2 -Wall- build-depends: base >= 4.8 && < 5- , criterion >= 1.0- , zip >= 0.1.3+ build-depends: base >= 4.8 && < 5.0+ , criterion >= 0.6.2 && < 1.2+ , zip >= 0.1.4 default-language: Haskell2010 source-repository head