Commit graph

717 commits

Author SHA1 Message Date
Mathijs van de Nes
d2ccfc16f7 Speed up Drop of ZipFileReader
Skip CRC and decompression when dropping an owned ZipFileReader
2018-06-17 15:16:14 +02:00
Mathijs van de Nes
38d1699853 Improve reading from non-seekable streams
You can now repeatedly call a function to iterate over all files in a
zip. This may give some suboptimal results, but is useful when dealing
with an incoming data stream.
2018-06-16 14:14:34 +02:00
Mathijs van de Nes
5b17e07086 Merge branch 'sequential-read' of https://github.com/FauxFaux/zip-rs into FauxFaux-sequential-read 2018-06-15 16:59:09 +02:00
Mathijs van de Nes
39ccaab76c Merge branch 'flate2-backends' of https://github.com/alexbool/zip-rs 2018-05-27 10:33:52 +02:00
Mathijs van de Nes
1cb79a0b91 Fix memory issues on corrupt zip files
Do not pre-allocate the number of files, as this might be an invalid
number.

Also give a more helpfull error message when the start of the central
directory could not be found.

Resolves #68
2018-05-23 19:43:46 +02:00
Mathijs van de Nes
00310c44d8 Expose zip file comment in ZipArchive
Resolves #71
2018-05-23 19:17:06 +02:00
Mathijs van de Nes
602952750e Update DEFAULT_VERSION
Use a more sane 'version made by' as we can write Bzip2 files
2018-05-22 23:36:56 +02:00
Mathijs van de Nes
ab9667aa5c Properly write 'version needed' in local file header
'version made by' was used instead of version needed by accident.

Resolves #72
2018-05-22 23:36:56 +02:00
Alexander Bulaev
fee626ba59 Control backend choice of flate2 2018-05-19 20:03:23 +03:00
Mathijs van de Nes
806147ac9e Fix sanitized_name test for Windows 2018-04-20 13:53:07 +02:00
Mathijs van de Nes
5e8c95e6ed Make santized_name part of the library
It is a common pitfall to use the name as-is during extraction. Adding
this function may prevent some of the issues.

Resolves #65
2018-04-20 13:35:20 +02:00
Mathijs van de Nes
fce3836059 Better handling of zips with invalid datetimes
The msdos datetime 0x00000000 is invalid. The Windows API would
(rightfully) return an ERROR_INVALID_PARAMETER for this when converting
it. If it is indeed an invalid error, we now return the zip datetime
'epoch' of 1980-01-01 00:00:00.

Resolves issue #61
2018-02-17 20:05:09 +01:00
Mathijs van de Nes
b2db9d55ae Merge branch 'deflate_feature' of https://github.com/jhwgh1968/zip-rs 2018-01-09 18:38:27 +01:00
Danilo Bargen
2469419a89 Fix compatibility with Rust <1.23 2018-01-08 08:26:49 +01:00
jhwgh1968
7c2d4e2901 Named the deflate algorithm feature gate "deflate" 2018-01-07 13:39:42 -06:00
jhwgh1968
19274b497a Made deflate compression into separate feature 2018-01-07 00:47:11 -06:00
Mathijs van de Nes
bbb279286a Remove unused import 2018-01-06 12:06:23 +01:00
rardiol
22194687c6 use flate2 1.0 2018-01-01 17:12:41 -03:00
Robin Syihab
c99d7c2758
Handle invalid zip header 2017-12-04 01:19:44 +07:00
Peter Williams
f85b5cb7b8 Add a test for ZIP64 with leading junk.
I constructed this file using a hack from the Zip manpage: if the input to a
Zip compression command is streamed on standard input, the output is given in
ZIP64 format since the tool doesn't know how big the input will be. I modified
the resulting file by adding some leading junk text and editing the non-ZIP64
end-of-central-directory structure to have 0xFFFF for its "number of files"
parameters, to help the test demonstrate that the ZIP64 data are being
properly read. (0xFFFF is the value used in the non-ZIP64 structure if the
archive actually has more than 65535 files.)
2017-08-12 14:42:32 -04:00
Peter Williams
4a297c32a8 Implement support for reading ZIP64 central-directory-end records
This provides only very basic ZIP64 support, but it allows us to properly read
archives with more than 65535 files, so long as none of the individual files
need ZIP64 support to be read.
2017-08-12 14:42:32 -04:00
Peter Williams
89f33c9348 Use u64's for internal file offsets.
These are better aligned with Rust's APIs, and lay the groundwork for more
convenient support of Zip64 files.
2017-08-12 14:42:32 -04:00
Mathijs van de Nes
2dae0d4a5c Add regression test for #40 2017-07-05 21:36:47 +02:00
Pascal Hertleif
57a6514a40 Prevent subtract with overflow
This changes assumes this only happens when the archive is invalid.

Fixes #40
2017-06-27 11:23:17 +02:00
Mathijs van de Nes
7aaedf6457 Add Copy/Clone for FileOptions
Resolves #38
2017-05-28 12:26:18 +02:00
Mathijs van de Nes
afb306d11d Merge branch 'feature/data-start' of https://github.com/bbqsrc/zip-rs 2017-04-28 12:43:03 +02:00
Mathijs van de Nes
240e1d469d Corrected some static -> const 2017-04-28 10:31:12 +02:00
Chris West (Faux)
0b5746150c read_single 2017-04-24 15:12:22 +01:00
Brendan Molloy
60596d15d9 Add data_start property to ZipFile 2017-04-17 15:53:10 +10:00
Stephen M. Coakley
fc746a09db
Handle data prepended to the zip 2017-04-08 03:04:18 -05:00
Mathijs van de Nes
633360a5a7 Ignore Io errors in extra field
IoErrors mean that the extra field was not long enough or contained an invalid lenght value.
These are ignored for now.

Resolves #32
2017-03-30 19:18:08 +02:00
Mathijs van de Nes
236050947a Fix a regression
Test would not compile anymore... weird
2017-03-30 19:03:25 +02:00
Jos van den Oever
93f676fa57 Add two simple tests. 2017-03-14 20:16:51 +01:00
Mihai STAN
7d85d8fb66 Fix writing to buffers.
Using SeekFrom::End(0) in finish_file for a buffer was movind the position
the the end of the buffer, not the last written byte.
2017-03-06 06:22:42 +02:00
Mathijs van de Nes
1831edbbdd Expose the raw file name of a file
We still do most operations with normal Strings, but a user can now also get the raw bytes.

Resolves #26
2017-02-12 17:18:40 +01:00
Mathijs van de Nes
d2d19f6539 Update the write API
This change adds a FileOptions struct. This struct can be filled using a builder pattern
to set the options for a file or folder.

With this change, we also introduce the option to set the (unix) permissions of a file or folder.
2016-10-30 09:09:50 +01:00
Mathijs van de Nes
82315c9511 Add comments to write.rs
Clarify which field means what when writing structures
2016-10-29 12:30:59 +02:00
Mathijs van de Nes
49e506c13c Fix types::System enum
Unix had incorrectly assigned the value 1 instead of 3
2016-10-29 12:30:30 +02:00
Don Rowe
1075ebf5f4 Add test for Display implementation for CompressionMethod 2016-10-03 21:34:14 -07:00
Don Rowe
a63b7315d0 Implement Display trait for CompressionMethod.
It's an alias to the Debug format, but we can't derive Display yet,
so we associate it explicitly.
2016-10-03 21:18:29 -07:00
Mathijs van de Nes
2a3fe099a6 Derive Debug for read::ZipArchive
Resolves #15
2016-08-08 17:34:02 +02:00
Mathijs van de Nes
1d2b43b2c0 Merge branch 'master' of git://github.com/efyang/zip-rs into efyang-master 2016-04-30 12:18:17 +02:00
Edward Yang
064b21b685 Add crc32 accessor for ZipFile 2016-04-29 17:04:08 -05:00
Mathijs van de Nes
e80213e250 Rename version to version_made_by
Also remove System for now
2016-04-27 14:30:00 +02:00
Alexander Koval
735bf4dfe4 Make system and version temporarilly private 2016-04-23 13:18:48 +03:00
Alexander Koval
1e935672bd Replace system attribute by enum 2016-04-23 13:12:28 +03:00
Alexander Koval
a16962cd2c Support for external file attributes 2016-04-23 10:31:54 +03:00
Mathijs van de Nes
d95c925ac2 Let ZipWriter::finish be called without consuming
Resolves #10
2016-02-22 19:54:18 +01:00
Mathijs van de Nes
aaa49eb4f1 Update to new bzip2 2016-02-22 19:46:07 +01:00
Mathijs van de Nes
7db32c9165 Remove unused parentheses 2016-02-02 21:17:42 +01:00