omnizip 0.3.19 → 0.3.21
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 +4 -4
- data/CHANGELOG.md +95 -3
- data/TODO.refactor/00-overview.md +2 -2
- data/TODO.refactor/07-respond-to-replacement.md +225 -79
- data/lib/omnizip/algorithm.rb +2 -2
- data/lib/omnizip/algorithms/bzip2.rb +1 -0
- data/lib/omnizip/algorithms/deflate.rb +1 -0
- data/lib/omnizip/algorithms/lzma/xz_utils_decoder.rb +3 -3
- data/lib/omnizip/algorithms/lzma.rb +11 -5
- data/lib/omnizip/algorithms/lzma2/encoder.rb +2 -0
- data/lib/omnizip/algorithms/lzma2/xz_encoder_adapter.rb +2 -0
- data/lib/omnizip/algorithms/lzma2.rb +2 -0
- data/lib/omnizip/algorithms/ppmd7.rb +2 -0
- data/lib/omnizip/algorithms/ppmd_base.rb +2 -0
- data/lib/omnizip/algorithms/registration.rb +1 -1
- data/lib/omnizip/algorithms/zstandard/encoder.rb +57 -18
- data/lib/omnizip/algorithms/zstandard/match_finder.rb +9 -5
- data/lib/omnizip/algorithms/zstandard.rb +1 -0
- data/lib/omnizip/chunked/writer.rb +3 -0
- data/lib/omnizip/commands/archive_extract_command.rb +3 -1
- data/lib/omnizip/commands/archive_list_command.rb +4 -3
- data/lib/omnizip/commands/profile_show_command.rb +2 -0
- data/lib/omnizip/convenience.rb +2 -0
- data/lib/omnizip/extraction/filter_chain.rb +4 -0
- data/lib/omnizip/extraction/selective_extractor.rb +7 -0
- data/lib/omnizip/file_type.rb +4 -0
- data/lib/omnizip/formats/ole.rb +2 -0
- data/lib/omnizip/formats/rar/decompressor.rb +1 -0
- data/lib/omnizip/formats/rar/license_validator.rb +2 -0
- data/lib/omnizip/formats/rar/reader.rb +1 -2
- data/lib/omnizip/formats/rpm.rb +1 -0
- data/lib/omnizip/formats/seven_zip/writer.rb +8 -0
- data/lib/omnizip/formats/tar/reader.rb +2 -0
- data/lib/omnizip/formats/xar/reader.rb +2 -0
- data/lib/omnizip/formats/xar/writer.rb +1 -0
- data/lib/omnizip/formats/xz.rb +2 -0
- data/lib/omnizip/formats/xz_impl/block_decoder.rb +3 -0
- data/lib/omnizip/formats/xz_impl/stream_decoder.rb +8 -0
- data/lib/omnizip/formats/zip/reader.rb +2 -0
- data/lib/omnizip/implementations/seven_zip/lzma/encoder.rb +1 -0
- data/lib/omnizip/implementations/xz_utils/lzma2/decoder.rb +4 -9
- data/lib/omnizip/implementations/xz_utils/lzma2/encoder.rb +1 -16
- data/lib/omnizip/io/buffered_input.rb +1 -0
- data/lib/omnizip/io/buffered_output.rb +1 -0
- data/lib/omnizip/io/source.rb +4 -0
- data/lib/omnizip/io/stream_manager.rb +3 -1
- data/lib/omnizip/link_handler.rb +2 -0
- data/lib/omnizip/metadata/metadata_validator.rb +2 -0
- data/lib/omnizip/models/filter_config.rb +2 -0
- data/lib/omnizip/version.rb +1 -1
- data/lib/omnizip/zip/file.rb +1 -1
- data/lib/omnizip/zip/input_stream.rb +2 -1
- metadata +1 -3
- data/lib/omnizip/algorithms/sevenzip_lzma2.rb +0 -119
- data/lib/omnizip/algorithms/xz_lzma2.rb +0 -114
data/lib/omnizip/version.rb
CHANGED
data/lib/omnizip/zip/file.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "fileutils"
|
|
4
|
+
require "stringio"
|
|
4
5
|
|
|
5
6
|
module Omnizip
|
|
6
7
|
module Zip
|
|
@@ -102,7 +103,6 @@ module Omnizip
|
|
|
102
103
|
content = read_entry_data(entry)
|
|
103
104
|
|
|
104
105
|
if block
|
|
105
|
-
require "stringio"
|
|
106
106
|
StringIO.open(content, "rb", &block)
|
|
107
107
|
else
|
|
108
108
|
content
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "stringio"
|
|
4
|
+
|
|
3
5
|
module Omnizip
|
|
4
6
|
module Zip
|
|
5
7
|
# Rubyzip-compatible InputStream class
|
|
@@ -88,7 +90,6 @@ module Omnizip
|
|
|
88
90
|
@current_entry.compression_method,
|
|
89
91
|
@current_entry.size,
|
|
90
92
|
)
|
|
91
|
-
require "stringio"
|
|
92
93
|
@current_entry_io = StringIO.new(decompressed, "rb")
|
|
93
94
|
end
|
|
94
95
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omnizip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -298,8 +298,6 @@ files:
|
|
|
298
298
|
- lib/omnizip/algorithms/ppmd8/restoration_method.rb
|
|
299
299
|
- lib/omnizip/algorithms/ppmd_base.rb
|
|
300
300
|
- lib/omnizip/algorithms/registration.rb
|
|
301
|
-
- lib/omnizip/algorithms/sevenzip_lzma2.rb
|
|
302
|
-
- lib/omnizip/algorithms/xz_lzma2.rb
|
|
303
301
|
- lib/omnizip/algorithms/zstandard.rb
|
|
304
302
|
- lib/omnizip/algorithms/zstandard/constants.rb
|
|
305
303
|
- lib/omnizip/algorithms/zstandard/decoder.rb
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (C) 2025 Ribose Inc.
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
-
# copy of this software and associated documentation files (the "Software"),
|
|
7
|
-
# to deal in the Software without restriction, including without limitation
|
|
8
|
-
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
9
|
-
# and/or sell copies of the Software, and to permit persons to whom the
|
|
10
|
-
# Software is furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
20
|
-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
21
|
-
# DEALINGS IN THE SOFTWARE.
|
|
22
|
-
|
|
23
|
-
module Omnizip
|
|
24
|
-
module Algorithms
|
|
25
|
-
# 7-Zip LZMA2 compression algorithm.
|
|
26
|
-
#
|
|
27
|
-
# This algorithm uses the 7-Zip SDK-compatible implementation of LZMA2,
|
|
28
|
-
# which provides compatibility with 7-Zip command-line tools.
|
|
29
|
-
#
|
|
30
|
-
# @example Compress data
|
|
31
|
-
# algorithm = Omnizip::AlgorithmRegistry.get(:sevenzip_lzma2).new(
|
|
32
|
-
# dict_size: 8 * 1024 * 1024
|
|
33
|
-
# )
|
|
34
|
-
# algorithm.compress(input_io, output_io)
|
|
35
|
-
#
|
|
36
|
-
# @example Decompress data
|
|
37
|
-
# algorithm = Omnizip::AlgorithmRegistry.get(:sevenzip_lzma2).new
|
|
38
|
-
# algorithm.decompress(input_io, output_io)
|
|
39
|
-
class SevenZipLZMA2 < Algorithm
|
|
40
|
-
# Get algorithm metadata.
|
|
41
|
-
#
|
|
42
|
-
# @return [Models::AlgorithmMetadata] Algorithm information
|
|
43
|
-
def self.metadata
|
|
44
|
-
Models::AlgorithmMetadata.new.tap do |meta|
|
|
45
|
-
meta.name = "sevenzip_lzma2"
|
|
46
|
-
meta.description = "LZMA2 compression (7-Zip SDK implementation)"
|
|
47
|
-
meta.version = "1.0.0"
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Compress data using 7-Zip LZMA2.
|
|
52
|
-
#
|
|
53
|
-
# @param input [IO, String] Input data
|
|
54
|
-
# @param output [IO] Output stream
|
|
55
|
-
# @return [void]
|
|
56
|
-
def compress(input, output)
|
|
57
|
-
# Apply filter if set
|
|
58
|
-
input_data = if input.is_a?(String)
|
|
59
|
-
if @filter
|
|
60
|
-
@filter.encode(input)
|
|
61
|
-
else
|
|
62
|
-
input
|
|
63
|
-
end
|
|
64
|
-
elsif input.respond_to?(:read)
|
|
65
|
-
data = input.read
|
|
66
|
-
if @filter
|
|
67
|
-
@filter.encode(data)
|
|
68
|
-
else
|
|
69
|
-
data
|
|
70
|
-
end
|
|
71
|
-
else
|
|
72
|
-
raise ArgumentError, "Input must be a String or IO"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Get encoding options
|
|
76
|
-
dict_size = @options.fetch(:dict_size, 8 * 1024 * 1024)
|
|
77
|
-
lc = @options.fetch(:lc, 3)
|
|
78
|
-
lp = @options.fetch(:lp, 0)
|
|
79
|
-
pb = @options.fetch(:pb, 2)
|
|
80
|
-
|
|
81
|
-
# Use existing LZMA2Encoder which wraps SimpleLZMA2Encoder
|
|
82
|
-
encoder = LZMA2::LZMA2Encoder.new(
|
|
83
|
-
dict_size: dict_size,
|
|
84
|
-
lc: lc,
|
|
85
|
-
lp: lp,
|
|
86
|
-
pb: pb,
|
|
87
|
-
standalone: false,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
compressed = encoder.encode(input_data)
|
|
91
|
-
output.write(compressed)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Decompress data using 7-Zip LZMA2.
|
|
95
|
-
#
|
|
96
|
-
# @param input [IO] Input stream
|
|
97
|
-
# @param output [IO] Output stream
|
|
98
|
-
# @return [void]
|
|
99
|
-
def decompress(input, output)
|
|
100
|
-
dict_size = @options.fetch(:dict_size, 8 * 1024 * 1024)
|
|
101
|
-
|
|
102
|
-
# Use existing LZMA2::Decoder
|
|
103
|
-
decoder = LZMA2::Decoder.new(input, raw_mode: true,
|
|
104
|
-
dict_size: dict_size)
|
|
105
|
-
decompressed = decoder.decode_stream
|
|
106
|
-
|
|
107
|
-
# Reverse filter if set
|
|
108
|
-
if @filter
|
|
109
|
-
decompressed = @filter.decode(decompressed)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
output.write(decompressed)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Register the algorithm
|
|
119
|
-
Omnizip::Algorithms::SevenZipLZMA2.register_algorithm
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (C) 2025 Ribose Inc.
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
-
# copy of this software and associated documentation files (the "Software"),
|
|
7
|
-
# to deal in the Software without restriction, including without limitation
|
|
8
|
-
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
9
|
-
# and/or sell copies of the Software, and to permit persons to whom the
|
|
10
|
-
# Software is furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
20
|
-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
21
|
-
# DEALINGS IN THE SOFTWARE.
|
|
22
|
-
|
|
23
|
-
module Omnizip
|
|
24
|
-
module Algorithms
|
|
25
|
-
# XZ Utils LZMA2 compression algorithm.
|
|
26
|
-
#
|
|
27
|
-
# This algorithm uses the XZ Utils implementation of LZMA2,
|
|
28
|
-
# which provides full compatibility with xz command-line tools.
|
|
29
|
-
#
|
|
30
|
-
# @example Compress data
|
|
31
|
-
# algorithm = Omnizip::AlgorithmRegistry.get(:xz_lzma2).new(
|
|
32
|
-
# dict_size: 8 * 1024 * 1024
|
|
33
|
-
# )
|
|
34
|
-
# algorithm.compress(input_io, output_io)
|
|
35
|
-
#
|
|
36
|
-
# @example Decompress data
|
|
37
|
-
# algorithm = Omnizip::AlgorithmRegistry.get(:xz_lzma2).new
|
|
38
|
-
# algorithm.decompress(input_io, output_io)
|
|
39
|
-
class XZLZMA2 < Algorithm
|
|
40
|
-
# Get algorithm metadata.
|
|
41
|
-
#
|
|
42
|
-
# @return [Models::AlgorithmMetadata] Algorithm information
|
|
43
|
-
def self.metadata
|
|
44
|
-
Models::AlgorithmMetadata.new.tap do |meta|
|
|
45
|
-
meta.name = "xz_lzma2"
|
|
46
|
-
meta.description = "LZMA2 compression (XZ Utils implementation)"
|
|
47
|
-
meta.version = "1.0.0"
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Compress data using XZ Utils LZMA2.
|
|
52
|
-
#
|
|
53
|
-
# @param input [IO, String] Input data
|
|
54
|
-
# @param output [IO] Output stream
|
|
55
|
-
# @return [void]
|
|
56
|
-
def compress(input, output)
|
|
57
|
-
input_data = if input.is_a?(String)
|
|
58
|
-
input
|
|
59
|
-
elsif input.respond_to?(:read)
|
|
60
|
-
input.read
|
|
61
|
-
else
|
|
62
|
-
raise ArgumentError, "Input must be a String or IO"
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Apply filter if set
|
|
66
|
-
if @filter
|
|
67
|
-
input_data = @filter.encode(input_data)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Get encoding options
|
|
71
|
-
dict_size = @options.fetch(:dict_size, 8 * 1024 * 1024)
|
|
72
|
-
lc = @options.fetch(:lc, 3)
|
|
73
|
-
lp = @options.fetch(:lp, 0)
|
|
74
|
-
pb = @options.fetch(:pb, 2)
|
|
75
|
-
standalone = @options.fetch(:standalone, false)
|
|
76
|
-
|
|
77
|
-
# Create encoder and compress
|
|
78
|
-
encoder = Implementations::XZUtils::LZMA2::Encoder.new(
|
|
79
|
-
dict_size: dict_size,
|
|
80
|
-
lc: lc,
|
|
81
|
-
lp: lp,
|
|
82
|
-
pb: pb,
|
|
83
|
-
standalone: standalone,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
compressed = encoder.encode(input_data)
|
|
87
|
-
output.write(compressed)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Decompress data using XZ Utils LZMA2.
|
|
91
|
-
#
|
|
92
|
-
# @param input [IO] Input stream
|
|
93
|
-
# @param output [IO] Output stream
|
|
94
|
-
# @return [void]
|
|
95
|
-
def decompress(input, output)
|
|
96
|
-
dict_size = @options.fetch(:dict_size, 8 * 1024 * 1024)
|
|
97
|
-
|
|
98
|
-
decoder = Implementations::XZUtils::LZMA2::Decoder.new(input,
|
|
99
|
-
raw_mode: true, dict_size: dict_size)
|
|
100
|
-
decompressed = decoder.decode_stream
|
|
101
|
-
|
|
102
|
-
# Reverse filter if set
|
|
103
|
-
if @filter
|
|
104
|
-
decompressed = @filter.decode(decompressed)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
output.write(decompressed)
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Register the algorithm
|
|
114
|
-
Omnizip::Algorithms::XZLZMA2.register_algorithm
|