45 Commits

Author SHA1 Message Date
Quytelda Kahja 1d44d56344 Add tests for skipping unneeded Zip64 fields
Add two tests to ensure addEntry and copyEntry don't add unneeded
Zip64 extra fields into the local file header.
2025-06-02 16:49:33 +02:00
Quytelda Kahja 7496676394 Add a 'StrictEntry' action for creating entries from strict data
When entry data is provided as a strict ByteString, we don't need to
stream the data to determine its uncompressed size. Thus, we can rule
out the need for Zip64 extra fields early.

This addresses issue #126.
2025-05-25 20:09:29 +02:00
Niklas Hambüchen c69cc3d6c2 Derive Show EntryDescription 2024-06-19 20:19:24 +02:00
Mark Karpov 63779b106a Improve the test suite to catch cases like issue 111 2024-04-20 21:00:47 +02:00
Mark Karpov da5df36c81 Fix corruption of large files when zip64 is used
Previously the code did not account for the fact that the initial stub local
header (with uncompressed and compressed sizes set to 0) could not serve for
correct estimation of the final local header size due to the fact that the
local header size was determined by the uncompressed and compressed sizes of
the corresponding data, which are only known after streaming of the data.
These sizes dictated whether or not a zip64 extra field entry should be
included in the header or not. Thus, before this fix there would be cases of
corruption where the final (longer) local header written by seeking back to
the beginning of the initial stub local header after the data had been
streamed would overwrite the beginning of the data.

This is fixed by

* always writing a zip64 entry in local headers, which does not violate the
  spec and will be safely ignored in the case of smaller entries, and
* respecting the spec more precisely where it says that whenever there is a
  zip64 extra field entry in a local header both uncompressed and compressed
  sizes must always be written.

This is deemed safe because the only source of size variation for local
headers is the uncompressed and compressed sizes of the corresponding data.
2024-04-20 09:33:59 +02:00
Mark Karpov 1848e8b3f9 Switch to GHC2021 2023-06-24 11:58:51 +02:00
Mark Karpov 2afd5b6cd6 Use Ormolu action v6 (Ormolu 0.5.0.0) 2022-05-12 15:23:34 +02:00
Mark Karpov f9a9099f35 Write the Zip64 extra field only when it is necessary 2021-10-29 20:20:10 +02:00
Mark Karpov fc967375c9 Improve the writing 2021-04-18 20:47:29 +02:00
Mark Karpov 892e2fcf59 Test with GHC 9.0.1 and 8.10.4 2021-03-06 18:24:13 +01:00
Alexander Vershilov fc1027caa6 Set file permissions on Unix platforms
Set user permissions on linux platform as follows:

  * if an existing file is added, use its permissions
  * if an entry is generated from a bytestring or a stream, use 0600

This behavior mimics the zip utility.
2021-01-18 23:55:03 +01:00
Csaba Hruska 7dee54beb6 Add support for Zstandard (zstd) compression method 2020-09-16 16:22:56 +02:00
Mark Karpov aff36c3010 Re-format with Ormolu 0.1.2.0 2020-07-10 22:29:56 +02:00
Mark Karpov 73951d0525 Formatting whims 2020-04-24 20:36:16 +02:00
Mark Karpov 8b358565e4 Format the source code with Ormolu 2020-04-23 22:22:12 +02:00
Mark Karpov 6816fb7ac5 Add ‘packDirRecur'’ 2020-04-12 11:48:13 +02:00
Alexander Vershilov 26b5746cbe Introduce helpers for setting permissions
It was very hard to set permissions using this library, as the permissions
were not properly documented. Here we try to solve the problem in 2 ways:

1. We add a low level documentation that explains how to work with
   permissions.
2. We introduce unix specific helpers that allow to describe permissions in
   a human readable way.

Unfortunately making those helpers OS agnostic is a pretty hard task we
enable them only on the Unix platforms.
2020-03-11 20:35:34 +01:00
Mark Karpov 717f6c27ef Speed up the test suite 2020-03-01 00:41:03 +01:00
Rodney Lorrimar 5a39029ceb Add Cabal flag to avoid the bzip2 C library dependency
The bzlib-conduit library is causing us trouble when trying to
cross-compile it for Windows.

The best thing to do in our case is to remove the dependency.

This change adds -fdisable-bzip2. Under this flag, if a caller
attempts to compress or decompress a BZip2 entry, then an exception
will be thrown.

Resolves #57
2019-11-30 16:46:42 +01:00
mrkkrp 299b6b4a68 Test with GHC 8.8.1 2019-09-25 23:13:48 +02:00
Ramakrishnan Muthukrishnan fe2e6cbc2d Allow to manipulate external file attributes (#52) 2018-09-22 19:39:46 +07:00
Mark Karpov a09152b92c Make ‘saveEntry’ and ‘unpackInto’ restore modification time (#47) 2018-05-24 11:00:44 +07:00
Mark Karpov 57261915b2 Test with GHC 8.4.1 (#44) 2018-03-11 22:18:53 +07:00
Mark Karpov e131160592 Stop depending on ‘path’, ‘path-io’, and ‘plan-b’ plus more (#43) 2018-02-09 20:33:35 +07:00
Mark Karpov 3f187d099d Switch to the newer Conduit API (#37) 2017-07-31 21:19:13 +07:00
mrkkrp 6676daeda2 Allow ‘path-0.6.0’
(Fix a wrong version boundary in the test component.)
2017-06-15 21:33:35 +07:00
mrkkrp c32f54d674 Drop redundant repetition of license text
[skip ci]
2017-05-24 17:15:50 +07:00
mrkkrp 5f7af58011 Remove the ‘zip64-ecd’ flag
Now that the situation is clear, I think it's pretty safe to remove this
additional run of the test suite. It's unlikely that we will run into new
Zip64-related issues.
2017-02-09 20:13:00 +03:00
Mark Karpov e5fe94940c Fix reading of empty Zip 64 archives
* Try to catch the Zip64 ECD issue on Travis
* Fix detection of end of central directory
2017-02-08 23:40:38 +04:00
mrkkrp 0927c6189e Include 2017 into copyright years range 2017-01-01 14:27:47 +03:00
mrkkrp 93c670fcc5 Calculate “version needed to extract” field
Close #14.

Two new features:

* Added explicit check of “version needed to extract”, so if archive
  uses some advanced features that we do not support yet, parsing fails.

* Value of “version needed to extract” field is now calculated
  dynamically with respect to actually used features, e.g. if you just
  store or deflate a not very big file, ‘2.0’ version will be
  written (previously we wrote ‘4.6’ unconditionally). This is needed to
  avoid scaring tools that can only handle basic Zip archives.
2016-04-09 14:55:44 +07:00
mrkkrp 7fef123c7f Speed-up tests for newer versions of ‘filepath’ 2016-03-04 10:42:19 +06:00
mrkkrp ec18d1cd3b Fix some tests 2016-03-03 21:51:11 +06:00
mrkkrp 0dd3af989f Finish the test suite
Close #1.
2016-03-02 20:37:36 +06:00
mrkkrp 9ebb986dbe Fix the test failures (dates out of range)
MS DOS time/date format is quite limited in range of dates it can
represent. Here we ensure that all ‘UTCTime’ values we use for testing
are in appropriate range.
2016-03-02 18:22:29 +06:00
mrkkrp 2548a201c4 Even more tests written… 2016-03-02 16:50:32 +06:00
mrkkrp 7e6d8025f7 Add ‘doesEntryExist’ and ‘getEntryDesc’
Close #7.
2016-03-02 13:49:32 +06:00
mrkkrp cb2e2b0a57 More tests: extra fields, renaming, and deletion 2016-03-02 12:57:43 +06:00
mrkkrp 9a5c934a12 Add even more tests… 2016-03-01 21:38:24 +06:00
mrkkrp 476bc01518 More tests written 2016-03-01 17:19:46 +06:00
mrkkrp e86bcbcf6d Improve coverage of ‘decodeCP437’ 2016-03-01 10:54:13 +06:00
mrkkrp 532e0f00ca More tests written… 2016-03-01 09:53:05 +06:00
mrkkrp 24869fe99b Some tests written 2016-02-29 15:21:10 +06:00
mrkkrp 6b0a6a9b85 Fix the build 2016-02-26 17:24:24 +06:00
mrkkrp 6bce0ee7a8 Initial decisions on dependencies and structure 2016-01-28 16:09:09 +06:00