Commit Graph

46 Commits

Author SHA1 Message Date
Robert Haines 1c06454985 Update minimum ruby version to 3.0.
All rubies before 3.0 are EOL and this is a major version bump, so it's
the right time to do this.
2024-03-01 22:14:48 +00:00
Robert Haines 2ffbfebb88 Document or hide classes from the docs. 2023-04-14 11:25:22 +01:00
Robert Haines f460da3afb Prevent unnecessary Zip64 data being stored.
With Zip64 write support enabled by default, it's important that we
only store the extra data when we need to. This commit ensures that
the Zip64 extra data is included for an entry if its size is over
4GB, or if we don't know how big it will be at the point of writing
the local header data.

This commit also removes the need for the Zip64Placeholder extra
data field. Now we just use the Zip64 field itself and ensure it's
filled in correctly.
2023-01-03 20:19:40 +00:00
Robert Haines 765cb316f1 Fix reading unknown extra fields.
When loading extra fields from both the central directory and local headers,
unknown fields were not merged correctly. They were being appended, which
means that we end up with the two versions stuck together - in some
cases duplicating the field completely.

This broke all kinds of things (like calculating the size of a local
header) in subtle ways.

This commit fixes this by implementing a new `Unknown` extra field type,
and making sure that when reading local and central extra fields they
are stored and preserved correctly. We cannot assume the unknown fields
use the same data in the local and central headers.

Fixes #505.
2021-11-19 19:53:38 +00:00
Robert Haines 193507b15a Adjust Layout/LineLength cop to 100 characters.
We'll get the line length down in stages...
2021-06-25 22:31:34 +01:00
Robert Haines fe998a5aec Fix Layout/EmptyLinesAroundAttributeAccessor cop. 2021-05-25 21:24:50 +01:00
Robert Haines e10badf68e Fix Style/FrozenStringLiteralComment cop. 2021-05-25 21:24:50 +01:00
Taichi Ishitani 0e4dc676a0 fix frozen string literal error 2021-05-25 21:24:50 +01:00
Robert Haines 8bafcbbc4d Remove dead code in extra_field/generic.rb (`==`).
From what I can tell this was erroneously copied out of extra_field.rb
during a refactor. It attempts to compare a non-existent Hash that used
to be inherited before the refactor. If this code had been left within
ExtraField it would make more sense, but as it's not needed there either
let's just remove it.

See 20d79feb99 for the refactor.
2020-10-03 18:27:20 +01:00
Robert Haines fe1d3c8da0 Fix reading Ux extra field.
As previously implemented the `uid` and `gid` fields could only ever be
read as 0, because they were being initialized to zero and then
memoization (`@uid ||= uid`) was used to 'save' the new value. Using `nil`
as the initial value for either of these fields breaks so many tests, so I
have fixed this by not using memoization instead. This is safe because it
is only the local extra field that holds these values for this type of
extra field.
2020-09-20 18:54:23 +01:00
Robert Haines c30d9dfb26 Configure Naming/MemoizedInstanceVariableName in source.
Rather than turn it off for a whole file, it's better to mark these
exceptions in comments.
2020-02-29 18:11:52 +00:00
Robert Haines 2dfe092728 Fix Style/UnpackFirst cop. 2020-02-15 16:26:32 +00:00
Robert Haines 45f4c2dc29 Fix Style/GuardClause cop. 2020-02-15 16:26:32 +00:00
Robert Haines cfe4972e71 Fix Layout/EmptyLineAfterGuardClause cop. 2020-02-15 16:26:32 +00:00
Robert Haines 98c6969c18 Fix Layout/SpaceAroundOperators cop. 2020-02-15 16:26:32 +00:00
Robert Haines ee028d2746 UniversalTime: more ruby-like (readable) code. 2019-12-15 22:42:09 +00:00
Robert Haines 9849500d73 UniversalTime: correctly parse included timestamps.
From the documentation: "...times that are present will appear in the
order indicated, but any combination of times may be omitted. (Creation
time may be present without access time, for example.)"

This fixes the parsing so that the times are read into the correct
fields, according to the flags. Before they were simply assumed to be in
order and all present.
2019-12-15 22:37:29 +00:00
Robert Haines a5e785c737 UniversalTime: better check for size on parse. 2019-12-15 22:26:06 +00:00
Robert Haines 65cfd8a9a5 UniversalTime: correctly pack/unpack the timestamps.
From the documentation: "The time values are in standard Unix signed-long
format, indicating the number of seconds since 1 January 1970 00:00:00."

The three time values were being unpacked with 'VVV', which is unsigned
32-bit, but they should be unpacked with 'l<l<l<': signed-long little
endian.
2019-12-15 22:26:06 +00:00
Robert Haines b58b97fe23 UniversalTime: correctly set the flags.
When a timestamp is set/unset the flags should reflect this.
2019-12-15 22:26:06 +00:00
Robert Haines 935a4f31a2 Make warning messages consistent.
And fix a few spelling mistakes.
2019-10-12 12:52:04 +01:00
Robert Haines 340379f080 Use `warn` instead of `puts` for messages from the library code.
`warn` has the advantage of easily being disabled by, the `-W0` interpreter
flag or setting $VERBOSE to nil.
2019-10-11 19:31:42 +01:00
Takumasa Ochi cf91112b57 Apply automatic correction by rubocop 2017-06-29 11:57:12 +09:00
Pavel Lobashov f7eec2dd76 fix rubocop cop Style/SpaceAroundOperators 2015-06-08 10:26:13 +03:00
Pavel Lobashov ce7e01a206 fix rubocop Style/CommentIndentation cop 2015-03-24 19:31:28 +03:00
Pavel Lobashov b920a1eb49 fix rubocop Style/GuardClause cop 2015-03-24 19:16:03 +03:00
Pavel Lobashov b9aefaffb5 fix rubocop Style/IfUnlessModifier cop 2015-03-24 19:09:22 +03:00
Pavel Lobashov 1ba81ff46f fix rubocop Style/NumericLiterals cop 2015-03-23 19:23:04 +03:00
Pavel Lobashov 6a7a22fece fix rubocop Style/MultilineOperationIndentation cop 2015-03-23 19:10:39 +03:00
Pavel.Lobashov abf9cbec23 fix rubocop Style/RedundantSelf cop 2015-03-22 19:30:24 +03:00
Pavel.Lobashov 06e5a9352d fix rubocop Style/ParenthesesAroundCondition cop 2015-03-22 19:25:35 +03:00
Pavel Lobashov b93ef1266f fix rubocop Style/StringLiterals cop 2015-03-21 11:27:44 +03:00
Pavel Lobashov f67cf18e45 fix rubocop Style/EmptyLinesAroundModuleBody cop 2015-03-21 11:22:47 +03:00
Pavel Lobashov eba5fa1983 fix rubocop Style/EmptyLinesAroundAccessModifier cop 2015-03-21 11:19:43 +03:00
Pavel Lobashov 0c6a10e631 fix rubocop Style/AndOr cop 2015-03-21 10:48:05 +03:00
Pavel Lobashov a2afbafacf fix rubocop Style/AndOr cop 2015-03-21 10:45:46 +03:00
Pavel.Lobashov 4ee6d6be39 fix rubocop Lint/UnusedMethodArgument cop 2015-03-20 23:09:41 +03:00
Pavel.Lobashov c45a639c54 fix rubocop Style/TrailingBlankLines cop 2015-03-20 22:45:50 +03:00
Pavel.Lobashov b7cda26ea6 fix rubocop Style/WhileUntilDo сщз 2015-03-20 22:38:09 +03:00
Henry Yang a7a11e33bd NTFS Extra Field (0x000a) support 2014-09-11 23:04:23 -07:00
Alexander Simonov 2697c7ea4f Fix #138 2014-03-09 20:38:24 +02:00
Sam Rawlins a68a36c759 Allocate less Arrays and Strings when writing a zip 2014-02-03 12:15:08 -08:00
Jeremy Stanley b87c95cc7e fix string encoding of zip64 header ids for ruby 2.0 2013-09-27 21:45:08 -06:00
Jeremy Stanley af165f5cbd Add read/write support for zip64 extensions
This commit adds the capability of creating archives larger than
4GB via zip64 extensions. It also fixes bugs reading archives of
this size (specifically, the 64-bit offset of the local file
header was not being read from the central directory entry).

To maximize compatibility, zip64 extensions are used only when
required. Unfortunately, at the time we write a local file header,
we don't know the size of the file and thus whether a Zip64
Extended Information Extra Field will be required. Therefore
this commit writes a 'placeholder' extra field to reserve space
for the zip64 entry, which will be written if necessary when
we update the local entry with the final sizes and CRC. I use
the signature "\x99\x99" for this field, following the example
of DotNetZip which does the same.

This commit also adds a rake task, zip64_full_test, which
fully tests zip64 by actually creating and verifying a 4GB zip
file. Please note, however, that this test requires UnZip
version 6.00 or newer, which may not be supplied by your OS.
This test doesn't run along with the main unit tests because
it takes a few minutes to complete.
2013-09-27 20:41:00 -06:00
Alexander Simonov 609de2ff48 Zip64 read-only support. Fix #81 2013-08-26 23:26:14 +03:00
Alexander Simonov 20d79feb99 Refactor ::Zip::Entry and ::Zip::ExtraField 2013-06-30 23:52:48 +03:00