omnizip 0.3.38 → 0.3.40
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 +58 -0
- data/README.adoc +139 -140
- data/config/formats/rar3_spec.yml +1 -0
- data/lib/omnizip/algorithm_registry.rb +7 -0
- data/lib/omnizip/algorithms/deflate64.rb +5 -8
- data/lib/omnizip/buffer/memory_extractor.rb +31 -6
- data/lib/omnizip/buffer/seven_zip_bridge.rb +154 -0
- data/lib/omnizip/buffer.rb +6 -5
- data/lib/omnizip/commands/archive_create_command.rb +7 -2
- data/lib/omnizip/commands/decompress_command.rb +29 -1
- data/lib/omnizip/commands/metadata_command.rb +67 -3
- data/lib/omnizip/converter/seven_zip_to_zip_strategy.rb +14 -52
- data/lib/omnizip/formats/rar/block_parser.rb +18 -8
- data/lib/omnizip/formats/rar/constants.rb +4 -0
- data/lib/omnizip/formats/rar/decompressor.rb +12 -8
- data/lib/omnizip/formats/rar/header.rb +7 -15
- data/lib/omnizip/formats/rar/reader.rb +18 -14
- data/lib/omnizip/formats/rar/writer.rb +121 -136
- data/lib/omnizip/formats/rar.rb +18 -8
- data/lib/omnizip/formats/rar3/reader.rb +11 -50
- data/lib/omnizip/formats/rar3/writer.rb +13 -10
- data/lib/omnizip/formats/rar3.rb +15 -0
- data/lib/omnizip/formats/rar5/reader.rb +8 -10
- data/lib/omnizip/formats/rar5.rb +15 -0
- data/lib/omnizip/formats/seven_zip/writer.rb +17 -0
- data/lib/omnizip/formats.rb +2 -0
- data/lib/omnizip/version.rb +1 -1
- data/readme-docs/api-usage.adoc +6 -5
- data/readme-docs/architecture.adoc +6 -5
- data/readme-docs/compression-algorithms.adoc +1 -1
- data/readme-docs/installation.adoc +1 -1
- data/readme-docs/performance-profiler.adoc +1 -1
- metadata +4 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Omnizip
|
|
4
|
+
module Formats
|
|
5
|
+
# Standalone RAR5 reader/writer tree (see Formats::Rar for the
|
|
6
|
+
# primary RAR support). Classes under this namespace load lazily;
|
|
7
|
+
# require "omnizip" first so sibling namespaces resolve.
|
|
8
|
+
module Rar5
|
|
9
|
+
autoload :Compressor, "omnizip/formats/rar5/compressor"
|
|
10
|
+
autoload :Decompressor, "omnizip/formats/rar5/decompressor"
|
|
11
|
+
autoload :Reader, "omnizip/formats/rar5/reader"
|
|
12
|
+
autoload :Writer, "omnizip/formats/rar5/writer"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -68,6 +68,23 @@ module Omnizip
|
|
|
68
68
|
@entries << entry
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# Add an explicit directory entry with no data or stream
|
|
72
|
+
#
|
|
73
|
+
# @param archive_path [String] Directory path inside the
|
|
74
|
+
# archive (trailing slash optional)
|
|
75
|
+
# @return [self]
|
|
76
|
+
def add_directory_entry(archive_path)
|
|
77
|
+
entry = Models::FileEntry.new
|
|
78
|
+
entry.name = archive_path.chomp("/")
|
|
79
|
+
entry.source_path = nil
|
|
80
|
+
entry.size = 0
|
|
81
|
+
entry.is_dir = true
|
|
82
|
+
entry.has_stream = false
|
|
83
|
+
entry.mtime = Time.now
|
|
84
|
+
@entries << entry
|
|
85
|
+
self
|
|
86
|
+
end
|
|
87
|
+
|
|
71
88
|
def write
|
|
72
89
|
# Collect any files from the collector (if add_file/add_directory was used)
|
|
73
90
|
collected_entries = @collector.collect_files
|
data/lib/omnizip/formats.rb
CHANGED
|
@@ -7,6 +7,8 @@ module Omnizip
|
|
|
7
7
|
autoload :SevenZip, "omnizip/formats/seven_zip"
|
|
8
8
|
autoload :Zip, "omnizip/formats/zip"
|
|
9
9
|
autoload :Rar, "omnizip/formats/rar"
|
|
10
|
+
autoload :Rar3, "omnizip/formats/rar3"
|
|
11
|
+
autoload :Rar5, "omnizip/formats/rar5"
|
|
10
12
|
autoload :Tar, "omnizip/formats/tar"
|
|
11
13
|
autoload :Gzip, "omnizip/formats/gzip"
|
|
12
14
|
autoload :Bzip2File, "omnizip/formats/bzip2_file"
|
data/lib/omnizip/version.rb
CHANGED
data/readme-docs/api-usage.adoc
CHANGED
|
@@ -340,7 +340,7 @@ Zstandard offers fast compression with good ratios, using the native library.
|
|
|
340
340
|
|
|
341
341
|
[source,ruby]
|
|
342
342
|
----
|
|
343
|
-
algorithm = Omnizip::AlgorithmRegistry.get(:
|
|
343
|
+
algorithm = Omnizip::AlgorithmRegistry.get(:zstandard).new(level: 3)
|
|
344
344
|
algorithm.compress(input, output)
|
|
345
345
|
----
|
|
346
346
|
|
|
@@ -418,13 +418,14 @@ Full support for creating and extracting .7z archives.
|
|
|
418
418
|
[source,ruby]
|
|
419
419
|
----
|
|
420
420
|
# Create archive
|
|
421
|
-
|
|
422
|
-
writer.add_file('input.txt')
|
|
423
|
-
writer.add_file('data.bin')
|
|
424
|
-
|
|
421
|
+
Omnizip::Formats::SevenZip.create('archive.7z') do |writer|
|
|
422
|
+
writer.add_file('input.txt')
|
|
423
|
+
writer.add_file('data.bin')
|
|
424
|
+
end
|
|
425
425
|
|
|
426
426
|
# Extract archive
|
|
427
427
|
reader = Omnizip::Formats::SevenZip::Reader.new('archive.7z')
|
|
428
|
+
reader.open
|
|
428
429
|
reader.extract_all('output_dir/')
|
|
429
430
|
reader.close
|
|
430
431
|
|
|
@@ -198,12 +198,13 @@ end
|
|
|
198
198
|
|
|
199
199
|
[source,ruby]
|
|
200
200
|
----
|
|
201
|
-
writer = Omnizip::Formats::SevenZip::Writer.new('archive.7z'
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
writer = Omnizip::Formats::SevenZip::Writer.new('archive.7z',
|
|
202
|
+
algorithm: :lzma2,
|
|
203
|
+
level: 9
|
|
204
|
+
)
|
|
204
205
|
writer.add_file('file1.txt')
|
|
205
206
|
writer.add_file('file2.txt')
|
|
206
|
-
writer.
|
|
207
|
+
writer.write
|
|
207
208
|
----
|
|
208
209
|
|
|
209
210
|
=== Adapter Pattern
|
|
@@ -245,7 +246,7 @@ end
|
|
|
245
246
|
|
|
246
247
|
# List all available
|
|
247
248
|
algorithms = Omnizip::AlgorithmRegistry.available
|
|
248
|
-
# => [:lzma, :lzma2, :bzip2, :ppmd7, :ppmd8, :deflate, :deflate64, :
|
|
249
|
+
# => [:lzma, :lzma2, :bzip2, :ppmd7, :ppmd8, :deflate, :deflate64, :zstandard]
|
|
249
250
|
----
|
|
250
251
|
|
|
251
252
|
=== Adding New Algorithms
|
|
@@ -63,7 +63,7 @@ require 'omnizip'
|
|
|
63
63
|
|
|
64
64
|
# Check available algorithms
|
|
65
65
|
puts Omnizip::AlgorithmRegistry.available.inspect
|
|
66
|
-
# => [:lzma, :lzma2, :bzip2, :ppmd7, :ppmd8, :deflate, :deflate64, :
|
|
66
|
+
# => [:lzma, :lzma2, :bzip2, :ppmd7, :ppmd8, :deflate, :deflate64, :zstandard]
|
|
67
67
|
|
|
68
68
|
# Get version
|
|
69
69
|
puts Omnizip::VERSION
|
|
@@ -302,7 +302,7 @@ def compare_algorithms(data, algorithms)
|
|
|
302
302
|
end
|
|
303
303
|
|
|
304
304
|
data = File.read('test_file.dat')
|
|
305
|
-
compare_algorithms(data, [:deflate, :lzma, :bzip2, :
|
|
305
|
+
compare_algorithms(data, [:deflate, :lzma, :bzip2, :zstandard])
|
|
306
306
|
----
|
|
307
307
|
|
|
308
308
|
=== Example 3: Memory Leak Detection
|
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.40
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -333,6 +333,7 @@ files:
|
|
|
333
333
|
- lib/omnizip/buffer.rb
|
|
334
334
|
- lib/omnizip/buffer/memory_archive.rb
|
|
335
335
|
- lib/omnizip/buffer/memory_extractor.rb
|
|
336
|
+
- lib/omnizip/buffer/seven_zip_bridge.rb
|
|
336
337
|
- lib/omnizip/checksum_registry.rb
|
|
337
338
|
- lib/omnizip/checksums.rb
|
|
338
339
|
- lib/omnizip/checksums/crc32.rb
|
|
@@ -504,10 +505,12 @@ files:
|
|
|
504
505
|
- lib/omnizip/formats/rar/recovery_record.rb
|
|
505
506
|
- lib/omnizip/formats/rar/volume_manager.rb
|
|
506
507
|
- lib/omnizip/formats/rar/writer.rb
|
|
508
|
+
- lib/omnizip/formats/rar3.rb
|
|
507
509
|
- lib/omnizip/formats/rar3/compressor.rb
|
|
508
510
|
- lib/omnizip/formats/rar3/decompressor.rb
|
|
509
511
|
- lib/omnizip/formats/rar3/reader.rb
|
|
510
512
|
- lib/omnizip/formats/rar3/writer.rb
|
|
513
|
+
- lib/omnizip/formats/rar5.rb
|
|
511
514
|
- lib/omnizip/formats/rar5/compressor.rb
|
|
512
515
|
- lib/omnizip/formats/rar5/decompressor.rb
|
|
513
516
|
- lib/omnizip/formats/rar5/reader.rb
|