Commit Graph

588 Commits

Author SHA1 Message Date
Robert Haines c0f20321ae Merge branch 'fix_depreciation_warning' of https://github.com/bbuchalter/rubyzip into bbuchalter-fix_depreciation_warning
* 'fix_depreciation_warning' of https://github.com/bbuchalter/rubyzip:
  Use default ruby behavior for Array.join
  Remove OUTPUT_FIELD_SEPARATOR-related test behaviors
  Set OUTPUT_FIELD_SEPARATOR to nil in test
  Prefer OUTPUT_RECORD_SEPARATOR to $\
  Prefer OUTPUT_FIELD_SEPARATOR to $,
2021-06-07 20:02:15 +01:00
Robert Haines 2410f2889e Restore file timestamps on all platforms.
Was only being done on Unix-type filesystems for some reason. Moved code
so that it is run for all files, whatever the underlying platform.
2021-06-06 16:17:22 +01:00
Robert Haines a6c6345084 Set restoring permissions and times as the default. 2021-06-06 16:17:22 +01:00
Robert Haines 684b69f330 Move the restore options to the top level.
This will ensure consistency between `File` and `Entry`.
2021-06-06 16:17:22 +01:00
Robert Haines a4e51f15fc Use constants instead of literals for some `fstype` calls. 2021-06-06 15:02:49 +01:00
Robert Haines 26b7f98c08 Use octal for more obvious definition of file-modes. 2021-06-06 15:02:49 +01:00
Robert Haines 9d8fc05c43 Refactor `get_entry` in `FileSystem::File(::Stat)`.
Rename it to `find_entry` because that is ultimately what is called on
the underlying zip file. Make `FileSystem::File#find_entry` public as it
need to be called from `FileSystem::File::Stat`, so now we can avoid
`__send__`. Neither class is documented anyway, so no harm done there.
2021-06-06 15:02:49 +01:00
Robert Haines 64a162ced4 Refactor `FileSystem::File::Stat.delegate_to_fs_file`.
Now uses `class_exec` instead of `class_eval`.
2021-06-06 15:02:49 +01:00
Robert Haines 99ecf3638f Remove spurious empty line at start of module. 2021-06-06 15:02:49 +01:00
Robert Haines 7b2e9c7970 Extract `FileSystem::File::Stat` from `FileSystem::File`. 2021-06-06 15:02:49 +01:00
Robert Haines d1329299c3 Extract `FileSystem::File` from the main filesystem file. 2021-06-06 15:02:49 +01:00
Robert Haines a1c9b63e61 Extract `FileSystem::Dir` from the main filesystem file. 2021-06-06 15:02:49 +01:00
Robert Haines 239baef845 Extract `DirectoryIterator` from the main filesystem file. 2021-06-06 15:02:49 +01:00
Robert Haines 204d084fdf Extract `ZipFileNameMapper` from the main filesystem file. 2021-06-06 15:02:49 +01:00
Jan-Joost Spanjers cdef4a5187 Prevent directory not empty error when running file_test on Windows
Fixed error:

ZipFileTest#test_open_buffer_no_op_does_not_change_file:
Errno::ENOTEMPTY: Directory not empty @ dir_s_rmdir - D:/a/_temp/d20210605-6612-1yi35sp
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1335:in `rmdir'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1335:in `block in remove_dir1'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1349:in `platform_support'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1334:in `remove_dir1'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1327:in `remove'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:689:in `block in remove_entry'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1384:in `ensure in postorder_traverse'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:1384:in `postorder_traverse'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/fileutils.rb:687:in `remove_entry'
    C:/hostedtoolcache/windows/Ruby/2.4.10/x64/lib/ruby/2.4.0/tmpdir.rb:101:in `mktmpdir'
    D:/a/rubyzip/rubyzip/test/file_test.rb:136:in `test_open_buffer_no_op_does_not_change_file'

Rationale:

File#dup does not behave like what you would expect from #dup on Ruby.
File#dup calls dup(2), which has OS dependant behavoir.

On Windows, calling File#dup seems to cause an extra reference
to an open file, which prevents deleting that file later.

With this commit, we leave out the call to File#dup on Windows.
It is not clear to me that removing this call has no undesired
consequences, but all other existing tests still succeed.
2021-06-06 14:44:20 +01:00
Jan-Joost Spanjers 8a5fef8074 Fix FileSystem::ZipFileNameMapper#expand_path on Windows
Fixes regression introduced by 0e4dc676a0.
2021-06-06 14:44:20 +01:00
Robert Haines b705085b09 `Entry#name_safe?` now allows Windows drive mappings. 2021-06-06 14:44:20 +01:00
Robert Haines 22a54853e6 Reinstate normalising pathname separators to `/`.
But only do it after we have set filename encoding appropriately to
avoid breaking multibyte characters with `\`s in them.

Fixes #324.
2021-06-04 16:22:45 +01:00
Robert Haines 1777a3ff53 Make sure `::Zip.force_entry_names_encoding` is reset.
It was the one option left out of `::Zip.reset!` for some reason.
2021-06-01 22:38:43 +01:00
Ariel Zelivansky f54e3b7f56 Fix improvement & fix NTFS 2021-05-30 10:28:27 +01:00
Ariel Zelivansky 01acd0488a Quick fix to prevent crash when mtime is nil 2021-05-30 10:28:27 +01:00
Robert Haines e70e1d3080 Add `InputStream#size`.
This will enable `InputStream` to be used with external APIs that expect
to be able to query the expected size of data they will receive, such as
S3.

Fixes #451.
2021-05-26 13:35:16 +01:00
Robert Haines ce08405c1a Fix (most) Style/MutableConstant cop errors.
The last one, in `ExtraField` needs a sizeable refactor to fix.
2021-05-25 21:50:06 +01:00
Robert Haines 530afe5d0c Fix Performance/BlockGivenWithExplicitBlock cop. 2021-05-25 21:24:50 +01:00
Robert Haines 55ed74c20e Fix/configure Style/AccessorGrouping cop. 2021-05-25 21:24:50 +01:00
Robert Haines fe998a5aec Fix Layout/EmptyLinesAroundAttributeAccessor cop. 2021-05-25 21:24:50 +01:00
Robert Haines efa23a84ba Fix Style/RedundantBegin cop. 2021-05-25 21:24:50 +01:00
Robert Haines 1b3f4bb7b8 Fix Style/HashConversion cop. 2021-05-25 21:24:50 +01:00
Robert Haines 606b5ffbb2 Fix Lint/EmptyBlock 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 8702876e55 Set the default `Entry` time to the file's mtime on Windows.
For some reason this was being skipped on Windows, but not Linux or
MacOS.
2021-05-18 21:59:54 +01:00
Robert Haines 34237efc00 Ensure that `Entry#time=` sets times as `DOSTime` objects.
Fixes #481.
2021-05-18 19:57:03 +01:00
Robert Haines 2b2e0ee568 Bump version to 3.0.0.
There are breaking changes in the recent PRs that have been merged.
2021-05-18 19:23:56 +01:00
Robert Haines 4ed35cae94 DosTime#<=> should return `nil` if other is not comparable. 2021-05-17 19:57:16 +01:00
Robert Haines 6e9f2976d1 Add temporary fix for JRuby to workaround Time cmp bug.
Workaround jruby/jruby#6668 until fix is released.

Version 9.2.18.0 is hopefully the version that will fix this, but we can
adjust the version accordingly if not.
2021-05-17 19:55:13 +01:00
Oleksandr Simonov 7f3bb29487
Merge pull request #464 from hainesr/remove_dosequals
Replace and deprecate `Zip::DOSTime#dos_equals`.
2021-05-03 10:22:13 +03:00
Oleksandr Simonov a0345420d8
Merge branch 'master' into compression_level 2021-02-14 14:26:12 +02:00
Oleksandr Simonov e397af3e0d
Merge pull request #447 from jlahtinen/fix_zlib_deflate_buffer_growth
Fix zlib deflate buffer growth
2021-02-14 14:24:36 +02:00
Oleksandr Simonov 9f29d09e02
Merge pull request #462 from hainesr/fix-zis-partial-read
Fix input stream partial read error.
2021-02-14 14:23:13 +02:00
Brian Buchalter ab9f546557 Use default ruby behavior for Array.join
Since we are using the default behavior of OUTPUT_FIELD_SEPERATOR
anyway, let's allow Ruby to maange that default for us, so if it should
change in the future, we don't have to change.
2021-01-26 04:43:26 -07:00
Robert Haines 5a4d1d8b6b Replace and deprecate `Zip::DOSTime#dos_equals`.
Having a specific 'does this instance equal another instance' method is
kind of annoying and breaks a number of things. Most obviously it breaks
comparing to `nil`: `nil.dos_equals(other)` will fail where
`nil == other` does not.

So this commit overrides `<=>` in `Zip::DOSTime` and deprecates
`dos_equals`.
2020-11-28 21:19:58 +00:00
Robert Haines 2ea805c951 Check `number_of_bytes` before comparison in read.
If an input stream has been read from, and left some data in the
internal buffer, then a subsequent `read`, with no amount of bytes to be
read having been specified, will raise an error when comparing to `nil`.
This fix checks that the number of bytes specified in the `read` is not
`nil` before comparing with the size of the internal buffer.

Fixes #461.
2020-11-08 17:20:53 +00: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 c2b9aa2893 Correctly read extra fields when opening a zip file.
Previously, only the extra fields stored in the central directory were
being read in. In reality it is often the case that the extra field in
the central directory is just a marker, and the full data is in the
local header. So we need to read both in and merge the two into the
final correct extra field. This merging infrastructure was already
implemented in the extra field code but we never actually read the
local extra fields in until now.

Reading the central directory headers and local entry headers seems
rather fragile, so we can't just read one over the other and hope to end
up with a correctly merged set of extra fields because this breaks other
things. So we need to specifically read the local extra field data and
merge just those bits.

This commit also fixes a couple of tests that were 'broken' by us now
reading extra fields in correctly!
2020-10-03 18:27:20 +01:00
Robert Haines f742994cf2 Abstract out reading extra fields in Entry.
Remove some (almost) duplicated code and get ready for the real fix.
2020-09-20 18:55:39 +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 f1dd724a3a Use constants for the compression level gp flags. 2020-08-31 17:48:08 +01:00
Robert Haines cf3f4339f6 Make sure that compression method is STORE for level 0.
Whatever the compression method that is set by the user, if the
compression level is set to 0 (no compression), then the entry should be
STORED. This mimics commandline tool behaviour and matches user
expectations.
2020-08-31 17:48:08 +01:00
Robert Haines 0620fba13d Don't use raw numbers for Entry compression types.
Constants for Store and Deflate are already available, so use them. It
might be sensible to remove these local versions, but they do have their
uses as a shortened form.
2020-08-31 17:48:08 +01:00
Robert Haines 156b0f3dee Tidy up accessors in `Entry`.
Remove a load of accessors from the 'public' API by not documenting
them, and remove access to `header_signature` completely.

Also, `Entry#extra` has been created to allow extra fields to be set
correctly after initialization.
2020-08-31 17:48:08 +01:00
Robert Haines e4ceedaa58 Use keyword arguments for the `Entry` initializer.
This greatly simplifies the creation of `Entry` objects when only a
couple of fields are not set to their defaults, while at the same time
allowing an `Entry` to be fully configured at creation time if
appropriate.

This fundamentally changes the `Entry` API and  means that some
convenience methods in `OutputStream` and `File` have needed to be
refactored.
2020-08-31 17:48:08 +01:00
Robert Haines 2775f529b4 Set the compression level general purpose flags. 2020-08-31 17:48:08 +01:00
Robert Haines 072fa27e78 Refactor `Entry#compression_method` access.
As per the conversation here [1], make `compression_method` a method and
enforce the correct type of compression for directories by default.

[1] https://github.com/rubyzip/rubyzip/pull/448#discussion_r436268506
2020-08-31 17:48:08 +01:00
Robert Haines d4bc24dcb3 Clean up `OutputStream` internals.
There was some fairly odd stuff going on in `put_next_entry` that
allowed for data within an `Entry` to be overridden and prevented an
`Entry` from being a single point of truth. Fixing this also simplifies
the code within `File` and still passes all tests.

Also, fixing the above means we can stop passing the compression level
around as a parameter and use the value stored in each `Entry` directly.

Let's keep `compression_level` out of the `Entry` public API though as
it only makes sense when writing an `Entry`: there doesn't seem to be an
obvious way to read what level of compression was used when reading an
`Entry` from a zip file.
2020-08-31 17:48:08 +01:00
Robert Haines 14451e63e7 Add setting a compression level to the File options.
It looks like it needs to be surfaced in `add` and `get_output_stream`.
The compression level defaults to whatever the global default is unless
it is overridden on opening the Zip::File.

Also needed to reorder some of the requires in the top-level module file
now that we are using defaults in the File class.
2020-08-31 17:48:08 +01:00
Robert Haines ef520b4b94 Add `compression_level` to the Entry API.
Allow an Entry to specify a compression level and pass this down to the
underlying OutputStream infrastructure. OutputStream has been able to
specify a compression level for a while but this has, up until now, only
ever been set to the default.

This fundamentally changes the API so will need a major version bump.
2020-08-31 17:48:08 +01:00
Robert Haines 0790695e8c Clean up OutputStream#init_next_entry.
There's no need for this private method to specify a default.
2020-08-31 17:48:08 +01:00
Joni Lahtinen 0fee529de5 Use guard instead of if else construct 2020-04-29 17:06:29 +03:00
Joni Lahtinen 5af76cecb5 Use Zlib::SYNC_FLUSH so buffer does not grow until finished
With JRuby implementation deflate would always return empty string
without Zlib::SYNC_FLUSH. That can cause memory problems when large
files are in deflate buffer as whole and red there with finish call at
once.
2020-04-29 16:38:33 +03:00
John Lees-Miller 69186f65cd Bump version to 2.3.0 2020-03-14 11:31:39 +00:00
John Lees-Miller fabacf1633
Merge pull request #440 from hainesr/rubocop-names
Rubocop name cops
2020-03-14 10:58:54 +00:00
Sebastian Henke 66324a711c Remove duplicate binmode call 2020-03-02 11:06:50 +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 f9b161eb32 Fix Naming/VariableName cop in the library code. 2020-02-29 18:11:52 +00:00
Robert Haines aa6ea05d45 Fix Naming/MethodParameterName cop in the library code. 2020-02-29 18:11:52 +00:00
Sebastian Henke b0ee2683b0 Set buffers to binmode by default 2020-02-19 18:48:13 +01:00
Robert Haines 846e704048 Fix Naming/BlockParameterName cop. 2020-02-17 22:35:08 +00:00
Robert Haines 989a565340 Fix Style/TrailingCommaInHashLiteral cop. 2020-02-15 16:26:32 +00:00
Robert Haines d07b36b2e6 Fix Style/TernaryParentheses cop. 2020-02-15 16:26:32 +00:00
Robert Haines 5ce4e13ddd Configure and fix Style/ClassCheck cop. 2020-02-15 16:26:32 +00:00
Robert Haines 6cab5922bc Configure and fix Metrics/LineLength cop.
Set a workable line length for now, and fix a couple of particularly bad
examples.

Also, turn off for the tests.
2020-02-15 16:26:32 +00:00
Robert Haines 0df6cb3059 Fix Style/SymbolProc cop. 2020-02-15 16:26:32 +00:00
Robert Haines bb3b4474fa Fix Style/SpecialGlobalVars cop. 2020-02-15 16:26:32 +00:00
Robert Haines 2f993221c0 Fix Style/Next cop. 2020-02-15 16:26:32 +00:00
Robert Haines 835843d992 Fix Naming/HeredocDelimiterCase cop. 2020-02-15 16:26:32 +00:00
Robert Haines d42c66ce2c Fix Style/MultilineWhenThen cop. 2020-02-15 16:26:32 +00:00
Robert Haines 2dfe092728 Fix Style/UnpackFirst cop. 2020-02-15 16:26:32 +00:00
Robert Haines 4e1b679c73 Fix Style/TrailingCommaInArrayLiteral cop. 2020-02-15 16:26:32 +00:00
Robert Haines 2e11a88fd2 Fix Style/StringLiterals 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 3121ad066f Fix Style/Alias cop. 2020-02-15 16:26:32 +00:00
Robert Haines 468a80ce02 Fix Style/IfInsideElse cop. 2020-02-15 16:26:32 +00:00
Robert Haines b3f241353a Fix Style/CommentedKeyword cop. 2020-02-15 16:26:32 +00:00
Robert Haines 5a1baf46ab Fix Style/RedundantReturn cop. 2020-02-15 16:26:32 +00:00
Robert Haines 61c83b2a1a Configure Layout/HashAlignment 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 fff2c41d68 Configure Lint/SuppressedException cop.
In the tests we can say "anything goes", but in the main body of the
code we should at least comment if we're not handling an exception
fully.
2020-02-15 16:26:32 +00:00
Robert Haines 0d49421711 Fix Lint/UselessAccessModifier cop. 2020-02-15 16:26:32 +00:00
Robert Haines b528cae084 Fix Lint/LiteralAsCondition cop.
This fixes Style/InfiniteLoop as a side-effect.
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 73e405acef Fix Security/Open cop errors. 2020-02-15 15:56:17 +00:00
taichi 976dbd3408 reverted the change according to comment below:
https://github.com/rubyzip/rubyzip/pull/431#discussion_r376698387
2020-02-08 19:54:45 +09:00
taichi b326d17438 use @+ operator instead of #dup to get unfrozen string 2020-02-05 11:40:56 +09:00
taichi 3bc85ccdec fixed frozen error caseud by frozen string literal 2020-02-05 11:30:30 +09:00
John Lees-Miller f42827e99c Bump version to 2.2.0 2020-02-01 13:24:50 +00:00
John Lees-Miller 040962a59f Remove unused error argument 2020-02-01 13:19:15 +00:00
John Lees-Miller 666fb8c03f
Merge pull request #427 from jspanjers/refactor-decompressor
Support decompressor plugins
2020-02-01 13:15:03 +00:00
Jan-Joost Spanjers a5d068d3e8 Support Decompressor plugins 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 2b7268373a Define compression methods 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 456bd4d92c Mimic IO#read return values in Decompressor#read 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c66277db58 Rename Decompressor#sysread to #read 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 00b525d76e Fix returned outbuf for Inflater#sysread 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers cda7127107 Add Decompressor#input_stream 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 5707c52a15 Move PassTruDecompressor#decompressed_size to Decompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 2bbcec0e34 Cleanup PassTruDecompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4ac83737b1 Cleanup Inflater 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers dd74bc0e73 Cleanup NullDecompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers b80ce3cc57 Make decryption generic for all compression methods
Now, STORED files can be decrypted, just like DEFLATED files.
2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4e28f7286c Untangle encryption and decompression 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 8f7c5caf29 Drop #produce_input from Decompressor class 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers d20a6834a3 Rework Inflater#produce_input to use sysread
This aligns Inflater#produce_input with
PassThruDecompresser#produce_input.
2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 1b6aeb2cd0 Replace Decompressor#input_finished? with #eof 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4a4c553b1e Move :eof from InputStream to AbastractInputStream 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers e072c57beb Add Entry#incomplete? 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c897bbdf77 Add Entry#encrypted? 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 0b7b78dc4a Encapsulate Zlib errors within DecompressionError 2020-01-26 15:34:13 +01:00
John Lees-Miller f6639f9b55 Bump version to 2.1.0 2020-01-25 18:12:57 +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 2d6b6e024b Ensure File#get/find_entry work consistently.
I have switched around the logic somewhat so that `get_entry` calls
`find_entry` and raises an exception if it gets `nil` back.
2019-10-31 18:12:18 +00:00
Robert Haines 0f6ca04a9d Set the default options in `Entry` the same as `File`. 2019-10-31 17:30:14 +00:00
Robert Haines 2bdd37d894 Add a convenience method for creating DOSTime instances.
DOSTime::from_time creates a DOSTime instance from a vanilla Time
instance.
2019-10-20 19:30:34 +01:00
Robert Haines 8c694d38ee Add functionality to restore file timestamps.
There has been an option in `Zip::File` (`:restore_times`) for a long
time, but it seems it has never worked. Firstly the actual timestamp of
an added file wasn't being saved, and secondly an extracted file wasn't
having its timestamp set correctly.

This commit fixes both of those issues, and adds tests to make sure.
2019-10-20 19:30:27 +01:00
Robert Haines 378293539d Make the attr_accessors in File more readable.
Note what the default is and that a couple of them will change at some
point soon.
2019-10-19 20:46:21 +01:00
Robert Haines 253457545e Correctly set/default options in the File class.
Fixes #395. Set the options to false for now for consistency.
2019-10-19 20:45:29 +01:00
John Lees-Miller 056c00cb16
Merge pull request #418 from hainesr/open-options
Add `options` parameter to `Zip::File.open`.
2019-10-19 17:38:38 +01:00
Robert Haines 3fea9958c2 Update comment for `Zip::File.open`. 2019-10-19 07:15:51 +01:00
Robert Haines f58e38012c Add the `options` parameter to `Zip::File.open`. 2019-10-19 07:04:04 +01: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
Robert Haines e87184200a Require 'tmpdir' only in the tests.
It's not used in the library code.
2019-09-27 16:28:02 +01:00
Robert Haines 506d557edc StreamableStream now uses the OS temp directory.
Rather than using the local folder.

Fixes #410
2019-09-27 16:13:56 +01:00
John Lees-Miller cb407b1065 Bump version to 2.0.0 2019-09-25 21:10:05 +01:00
John Lees-Miller 7c65e1e359 Bump version to 1.3.0 2019-09-25 19:59:24 +01:00
John Lees-Miller 97cb6aefe6 Warn when an entry size is invalid 2019-09-18 18:34:23 +01:00
John Lees-Miller 7849f7362a Default validate_entry_sizes to false for 1.3 release 2019-09-15 15:23:35 +01:00
John Lees-Miller 4167f0ce67 Validate entry sizes when extracting 2019-09-15 15:11:35 +01:00
Robert Haines ecb2776218 Zip::File.add_stored() to add uncompressed files.
Adding uncompressed files to a zip archive can be overly complex, so
this convenience method makes it easier.
2019-09-14 13:58:30 +01:00
John Lees-Miller 0d85cb6a49 Bump to 1.2.4 2019-09-06 18:01:30 +01:00
John Lees-Miller 7fbaf1e6c0
Merge pull request #360 from hainesr/fix-open-buffer
Fix #280 - `open_buffer` mangles the content of the buffer it is given.
2019-09-05 18:48:39 +01:00
John Lees-Miller 6f0b219265
Merge pull request #393 from rubyzip/v1-2-3
Bump version to 1.2.3
2019-05-23 19:33:53 +02:00
John Lees-Miller fb1c230cac Bump version to 1.2.3 2019-03-22 18:14:23 +02:00
John Lees-Miller ad15c3c494 Allow tilde in zip entry names
Use absolute_path rather than expand_path to allow tilde to pass through
unchanged. Otherwise, we try to expand it to a home directory.
2019-03-22 16:30:25 +02:00
John Lees-Miller bb3488723f
Merge pull request #385 from mihyaeru21/remove-commas
remove some strange commas
2019-03-21 22:22:32 +02:00
John Lees-Miller 3219d8e5af
Merge pull request #390 from taichi-ishitani/master
fixed FrozenError caused by frozen-string-literal
2019-03-21 21:58:17 +02:00
taichi 74f0d4eabb fixed errors caused by frozen-string-literal 2019-02-28 01:23:29 +09:00