archive-zip 0.11.0 → 0.13.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/NEWS.md +12 -0
- data/README.md +2 -1
- data/lib/archive/support/ioextensions.rb +5 -7
- data/lib/archive/support/iowindow.rb +34 -87
- data/lib/archive/support/stringio.rb +27 -0
- data/lib/archive/support/zlib.rb +0 -435
- data/lib/archive/zip/codec/deflate/reader.rb +187 -0
- data/lib/archive/zip/codec/deflate/writer.rb +209 -0
- data/lib/archive/zip/codec/deflate.rb +92 -244
- data/lib/archive/zip/codec/null_encryption.rb +4 -184
- data/lib/archive/zip/codec/store/reader.rb +97 -0
- data/lib/archive/zip/codec/store/writer.rb +78 -0
- data/lib/archive/zip/codec/store.rb +6 -231
- data/lib/archive/zip/codec/traditional_encryption/base.rb +85 -0
- data/lib/archive/zip/codec/traditional_encryption/reader.rb +65 -0
- data/lib/archive/zip/codec/traditional_encryption/writer.rb +71 -0
- data/lib/archive/zip/codec/traditional_encryption.rb +6 -360
- data/lib/archive/zip/codec.rb +2 -2
- data/lib/archive/zip/dos_time.rb +103 -0
- data/lib/archive/zip/entry.rb +86 -70
- data/lib/archive/zip.rb +2 -5
- metadata +37 -227
- data/.yardopts +0 -1
- data/Rakefile +0 -247
- data/lib/archive/support/binary_stringio.rb +0 -30
- data/lib/archive/support/integer.rb +0 -13
- data/lib/archive/support/io-like.rb +0 -14
- data/lib/archive/support/time.rb +0 -119
- data/lib/archive/zip/version.rb +0 -6
- data/spec/archive/dos_time_spec.rb +0 -113
- data/spec/archive/zip/archive_spec.rb +0 -54
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +0 -44
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +0 -45
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +0 -23
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +0 -74
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +0 -39
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +0 -48
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +0 -111
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +0 -20
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +0 -20
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +0 -74
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/deflate/fixtures/classes.rb +0 -25
- data/spec/archive/zip/codec/deflate/fixtures/compressed_file.bin +0 -1
- data/spec/archive/zip/codec/deflate/fixtures/compressed_file_nocomp.bin +0 -0
- data/spec/archive/zip/codec/deflate/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +0 -34
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +0 -16
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +0 -29
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +0 -26
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +0 -27
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +0 -59
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +0 -23
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +0 -34
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +0 -16
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +0 -28
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +0 -52
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +0 -31
- data/spec/archive/zip/codec/null_encryption/fixtures/classes.rb +0 -12
- data/spec/archive/zip/codec/null_encryption/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +0 -77
- data/spec/archive/zip/codec/store/compress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/store/compress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +0 -28
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +0 -52
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +0 -31
- data/spec/archive/zip/codec/store/compress/write_spec.rb +0 -29
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +0 -34
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +0 -75
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +0 -16
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +0 -29
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +0 -26
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +0 -27
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +0 -59
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +0 -23
- data/spec/archive/zip/codec/store/fixtures/classes.rb +0 -12
- data/spec/archive/zip/codec/store/fixtures/raw_file.txt +0 -10
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +0 -53
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +0 -20
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +0 -43
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +0 -127
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +0 -36
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +0 -80
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +0 -27
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +0 -53
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +0 -20
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +0 -41
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +0 -39
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +0 -73
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +0 -40
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +0 -114
- data/spec/archive/zip/codec/traditional_encryption/fixtures/classes.rb +0 -27
- data/spec/archive/zip/codec/traditional_encryption/fixtures/encrypted_file.bin +0 -0
- data/spec/archive/zip/codec/traditional_encryption/fixtures/raw_file.txt +0 -10
- data/spec/binary_stringio/new_spec.rb +0 -40
- data/spec/binary_stringio/set_encoding_spec.rb +0 -17
- data/spec/ioextensions/read_exactly_spec.rb +0 -52
- data/spec/zlib/fixtures/classes.rb +0 -65
- data/spec/zlib/fixtures/compressed_file.bin +0 -1
- data/spec/zlib/fixtures/compressed_file_gzip.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_huffman.bin +0 -2
- data/spec/zlib/fixtures/compressed_file_minmem.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_minwin.bin +0 -1
- data/spec/zlib/fixtures/compressed_file_nocomp.bin +0 -0
- data/spec/zlib/fixtures/compressed_file_raw.bin +0 -1
- data/spec/zlib/fixtures/raw_file.txt +0 -10
- data/spec/zlib/zreader/checksum_spec.rb +0 -42
- data/spec/zlib/zreader/close_spec.rb +0 -16
- data/spec/zlib/zreader/compressed_size_spec.rb +0 -20
- data/spec/zlib/zreader/new_spec.rb +0 -43
- data/spec/zlib/zreader/open_spec.rb +0 -51
- data/spec/zlib/zreader/read_spec.rb +0 -58
- data/spec/zlib/zreader/rewind_spec.rb +0 -25
- data/spec/zlib/zreader/seek_spec.rb +0 -57
- data/spec/zlib/zreader/tell_spec.rb +0 -23
- data/spec/zlib/zreader/uncompressed_size_spec.rb +0 -20
- data/spec/zlib/zwriter/checksum_spec.rb +0 -43
- data/spec/zlib/zwriter/close_spec.rb +0 -16
- data/spec/zlib/zwriter/compressed_size_spec.rb +0 -21
- data/spec/zlib/zwriter/new_spec.rb +0 -66
- data/spec/zlib/zwriter/open_spec.rb +0 -70
- data/spec/zlib/zwriter/rewind_spec.rb +0 -28
- data/spec/zlib/zwriter/seek_spec.rb +0 -52
- data/spec/zlib/zwriter/tell_spec.rb +0 -31
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +0 -21
- data/spec/zlib/zwriter/write_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1392110deef4d2f5d326613b369c129ba6c59802c8951d0f93c71f98f70e7b8c
|
4
|
+
data.tar.gz: 7d3d4fee38aa65051e96ec62364ee0642d0219488bb272e04c062e227735da75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46f9a08a470b353fd154e2d958c7ccd4454494a02f89d105b1cc567f6c66ca3ee284b49082e0875bbcbadd2da70ca7def0a0161efa1dfa0a2fba24029034712
|
7
|
+
data.tar.gz: c783d1001480fe8ef5756103101989e421855fd6f7435199bd29d338ce30745dda7ee2838b68a76201a9ddba04ee99f1de4515415ff087ab58d67b91d1dbfab8
|
data/LICENSE
CHANGED
data/NEWS.md
CHANGED
@@ -6,6 +6,18 @@ detailed information is available in the rest of the documentation.
|
|
6
6
|
**NOTE:** Date stamps in the following entries are in YYYY/MM/DD format.
|
7
7
|
|
8
8
|
|
9
|
+
## v0.13.0.pre1 (2025/05/25)
|
10
|
+
|
11
|
+
* Upgrade io-like dependency to 0.4.0.pre1
|
12
|
+
* Add more test coverage
|
13
|
+
|
14
|
+
## v0.12.0 (2019/02/28)
|
15
|
+
|
16
|
+
### Fixes
|
17
|
+
|
18
|
+
* Check for codec availability before attempting to initialize a codec instance
|
19
|
+
during extraction. (Kouhei Sutou)
|
20
|
+
|
9
21
|
## v0.11.0 (2018/01/28)
|
10
22
|
|
11
23
|
### Fixes
|
data/README.md
CHANGED
@@ -183,6 +183,7 @@ Thanks to all contributors. Without your help this project would not exist.
|
|
183
183
|
* Jeremy Bopp :: jeremy@bopp.net
|
184
184
|
* Akira Matsuda :: ronnie@dio.jp
|
185
185
|
* Tatsuya Sato :: tatsuya.b.sato@rakuten.com
|
186
|
+
* Kouhei Sutou :: kou@clear-code.com
|
186
187
|
|
187
188
|
## CONTRIBUTING
|
188
189
|
|
@@ -229,7 +230,7 @@ be more easily accepted if they are consistent with the rest of the code.
|
|
229
230
|
```
|
230
231
|
(The MIT License)
|
231
232
|
|
232
|
-
Copyright (c)
|
233
|
+
Copyright (c) 2025 Jeremy Bopp
|
233
234
|
|
234
235
|
Permission is hereby granted, free of charge, to any person obtaining
|
235
236
|
a copy of this software and associated documentation files (the
|
@@ -4,13 +4,11 @@
|
|
4
4
|
module IOExtensions
|
5
5
|
# Reads and returns exactly _length_ bytes from _io_ using the read method on
|
6
6
|
# _io_. If there is insufficient data available, an EOFError is raised.
|
7
|
-
def self.read_exactly(io, length
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
raise EOFError, 'unexpected end of file' if internal.nil?
|
12
|
-
buffer << internal
|
7
|
+
def self.read_exactly(io, length)
|
8
|
+
result = io.read(length)
|
9
|
+
if result.nil? || result.bytesize < length
|
10
|
+
raise EOFError, 'unexpected end of file'
|
13
11
|
end
|
14
|
-
|
12
|
+
result
|
15
13
|
end
|
16
14
|
end
|
@@ -1,115 +1,62 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
# IOWindow represents an IO object which wraps another one allowing read
|
6
|
-
#
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# Creates a new instance of this class using _io_ as the data source
|
13
|
-
# and where _window_position_ and _window_size_ define the location and size
|
14
|
-
# of data window respectively.
|
3
|
+
require 'io/like_helpers/delegated_io'
|
4
|
+
|
5
|
+
# IOWindow represents an IO object which wraps another one allowing read access
|
6
|
+
# to a subset of the data within the stream.
|
7
|
+
class IOWindow < IO::LikeHelpers::DelegatedIO
|
8
|
+
# Creates a new instance of this class using _delegate_ as the data source and
|
9
|
+
# where _window_position_ and _window_size_ define the location and size of
|
10
|
+
# data window respectively.
|
15
11
|
#
|
16
|
-
#
|
17
|
-
# must be an integer greater than or equal to 0. _window_size_ must be an
|
18
|
-
# integer greater than or equal to 0.
|
19
|
-
def initialize(io, window_position, window_size)
|
20
|
-
@io = io
|
21
|
-
@unbuffered_pos = 0
|
22
|
-
self.window_position = window_position
|
23
|
-
self.window_size = window_size
|
24
|
-
end
|
25
|
-
|
26
|
-
# The file position at which this window begins.
|
27
|
-
attr_reader :window_position
|
28
|
-
|
29
|
-
# Set the file position at which this window begins.
|
12
|
+
# _delegate_ must be opened for reading and must be seekable.
|
30
13
|
# _window_position_ must be an integer greater than or equal to 0.
|
31
|
-
def window_position=(window_position)
|
32
|
-
unless window_position.respond_to?(:to_int) then
|
33
|
-
raise TypeError, "can't convert #{window_position.class} into Integer"
|
34
|
-
end
|
35
|
-
window_position = window_position.to_int
|
36
|
-
if window_position < 0 then
|
37
|
-
raise ArgumentError, 'non-positive window position given'
|
38
|
-
end
|
39
|
-
|
40
|
-
@window_position = window_position
|
41
|
-
end
|
42
|
-
|
43
|
-
# The size of the window.
|
44
|
-
attr_reader :window_size
|
45
|
-
|
46
|
-
# Set the size of the window.
|
47
14
|
# _window_size_ must be an integer greater than or equal to 0.
|
48
|
-
def
|
49
|
-
|
50
|
-
|
15
|
+
def initialize(delegate, window_position, window_size, autoclose: true)
|
16
|
+
super(delegate, autoclose: autoclose)
|
17
|
+
|
18
|
+
@window_position = Integer(window_position)
|
19
|
+
if @window_position < 0
|
20
|
+
raise ArgumentError, 'window_position must be at least 0'
|
51
21
|
end
|
52
|
-
window_size = window_size
|
53
|
-
raise ArgumentError, '
|
22
|
+
@window_size = Integer(window_size)
|
23
|
+
raise ArgumentError, 'window_size must be at least 0' if @window_size < 0
|
54
24
|
|
55
|
-
@
|
25
|
+
@pos = 0
|
56
26
|
end
|
57
27
|
|
58
|
-
|
59
|
-
|
60
|
-
def unbuffered_read(length)
|
61
|
-
restore_self
|
62
|
-
|
28
|
+
def read(length, buffer: nil, buffer_offset: 0)
|
63
29
|
# Error out if the end of the window is reached.
|
64
|
-
raise EOFError, 'end of file reached' if @
|
30
|
+
raise EOFError, 'end of file reached' if @pos >= @window_size
|
65
31
|
|
66
32
|
# Limit the read operation to the window.
|
67
|
-
length = @window_size - @
|
33
|
+
length = @window_size - @pos if @pos + length > @window_size
|
68
34
|
|
69
35
|
# Fill a buffer with the data from the delegate.
|
70
|
-
|
71
|
-
|
72
|
-
raise EOFError, 'end of file reached' if buffer.nil?
|
36
|
+
result = super(length, buffer: buffer, buffer_offset: buffer_offset)
|
37
|
+
return result if Symbol === result
|
73
38
|
|
74
|
-
|
75
|
-
@unbuffered_pos += buffer.length
|
39
|
+
@pos += buffer.nil? ? result.bytesize : result
|
76
40
|
|
77
|
-
|
78
|
-
ensure
|
79
|
-
restore_delegate
|
41
|
+
result
|
80
42
|
end
|
81
43
|
|
82
|
-
def
|
83
|
-
# Convert the
|
44
|
+
def seek(amount, whence = IO::SEEK_SET)
|
45
|
+
# Convert the amount into an absolute position.
|
84
46
|
case whence
|
85
47
|
when IO::SEEK_SET
|
86
|
-
new_pos =
|
48
|
+
new_pos = amount
|
87
49
|
when IO::SEEK_CUR
|
88
|
-
new_pos = @
|
50
|
+
new_pos = @pos + amount
|
89
51
|
when IO::SEEK_END
|
90
|
-
new_pos = @window_size +
|
52
|
+
new_pos = @window_size + amount
|
91
53
|
end
|
92
54
|
|
93
55
|
# Error out if the position is outside the window.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@unbuffered_pos = new_pos
|
98
|
-
end
|
99
|
-
|
100
|
-
# Restores the state of the delegate IO object to that saved by a prior call
|
101
|
-
# to #restore_self.
|
102
|
-
def restore_delegate
|
103
|
-
@io.pos = @delegate_pos
|
104
|
-
@io.lineno = @delegate_lineno
|
105
|
-
end
|
56
|
+
if new_pos < 0 || new_pos > @window_size
|
57
|
+
raise Errno::EINVAL, 'Invalid argument'
|
58
|
+
end
|
106
59
|
|
107
|
-
|
108
|
-
# using #restore_delegate and then configures the delegate so as to restore
|
109
|
-
# the state of this object.
|
110
|
-
def restore_self
|
111
|
-
@delegate_pos = @io.pos
|
112
|
-
@delegate_lineno = @io.lineno
|
113
|
-
@io.pos = @window_position + @unbuffered_pos
|
60
|
+
@pos = super(new_pos + @window_position, IO::SEEK_SET) - @window_position
|
114
61
|
end
|
115
62
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
##
|
6
|
+
# This extends StringIO to include additional methods required by the io-like
|
7
|
+
# library to wrap IO objects.
|
8
|
+
class StringIO
|
9
|
+
unless public_method_defined?(:sysseek)
|
10
|
+
def sysseek(offset, whence = IO::SEEK_SET)
|
11
|
+
seek(offset, whence)
|
12
|
+
pos
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
unless public_method_defined?(:nonblock?)
|
17
|
+
def nonblock?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
unless public_method_defined?(:wait)
|
23
|
+
def wait(*args)
|
24
|
+
return true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|