omnizip 0.3.13 → 0.3.14

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/omnizip/algorithm.rb +36 -1
  3. data/lib/omnizip/algorithms/bzip2.rb +1 -3
  4. data/lib/omnizip/algorithms/deflate.rb +1 -3
  5. data/lib/omnizip/algorithms/deflate64.rb +2 -2
  6. data/lib/omnizip/algorithms/lzma.rb +1 -1
  7. data/lib/omnizip/algorithms/lzma2.rb +4 -12
  8. data/lib/omnizip/algorithms/zstandard.rb +1 -3
  9. data/lib/omnizip/algorithms.rb +14 -1
  10. data/lib/omnizip/commands/archive_list_command.rb +9 -7
  11. data/lib/omnizip/entry.rb +44 -0
  12. data/lib/omnizip/extraction/selective_extractor.rb +2 -10
  13. data/lib/omnizip/filter_pipeline.rb +1 -1
  14. data/lib/omnizip/filter_registry.rb +18 -16
  15. data/lib/omnizip/filters/bcj2.rb +1 -1
  16. data/lib/omnizip/filters/bcj_arm.rb +1 -1
  17. data/lib/omnizip/filters/bcj_arm64.rb +1 -1
  18. data/lib/omnizip/filters/bcj_ia64.rb +1 -1
  19. data/lib/omnizip/filters/bcj_ppc.rb +1 -1
  20. data/lib/omnizip/filters/bcj_sparc.rb +1 -1
  21. data/lib/omnizip/filters/bcj_x86.rb +1 -1
  22. data/lib/omnizip/filters.rb +0 -2
  23. data/lib/omnizip/formats/bzip2_file.rb +0 -7
  24. data/lib/omnizip/formats/cpio/entry.rb +6 -0
  25. data/lib/omnizip/formats/cpio.rb +0 -6
  26. data/lib/omnizip/formats/gzip.rb +0 -7
  27. data/lib/omnizip/formats/iso/directory_record.rb +7 -0
  28. data/lib/omnizip/formats/iso.rb +0 -5
  29. data/lib/omnizip/formats/lzip.rb +0 -7
  30. data/lib/omnizip/formats/lzma_alone.rb +0 -6
  31. data/lib/omnizip/formats/msi/entry.rb +6 -0
  32. data/lib/omnizip/formats/msi.rb +0 -9
  33. data/lib/omnizip/formats/ole/dirent.rb +6 -0
  34. data/lib/omnizip/formats/ole.rb +0 -9
  35. data/lib/omnizip/formats/rar.rb +0 -6
  36. data/lib/omnizip/formats/rar3/reader.rb +7 -0
  37. data/lib/omnizip/formats/rar5/reader.rb +7 -0
  38. data/lib/omnizip/formats/rpm/entry.rb +6 -0
  39. data/lib/omnizip/formats/seven_zip/models/file_entry.rb +7 -0
  40. data/lib/omnizip/formats/seven_zip.rb +0 -6
  41. data/lib/omnizip/formats/tar/entry.rb +6 -0
  42. data/lib/omnizip/formats/tar.rb +0 -6
  43. data/lib/omnizip/formats/xar/entry.rb +6 -0
  44. data/lib/omnizip/formats/xar.rb +0 -6
  45. data/lib/omnizip/formats/zip.rb +0 -6
  46. data/lib/omnizip/implementations.rb +18 -4
  47. data/lib/omnizip/metadata/entry_metadata.rb +7 -0
  48. data/lib/omnizip/parallel/engine.rb +48 -0
  49. data/lib/omnizip/parallel/parallel_compressor.rb +5 -16
  50. data/lib/omnizip/parallel/parallel_extractor.rb +5 -16
  51. data/lib/omnizip/parallel.rb +1 -0
  52. data/lib/omnizip/registry.rb +0 -1
  53. data/lib/omnizip/rubyzip_compat.rb +0 -1
  54. data/lib/omnizip/version.rb +1 -1
  55. data/lib/omnizip/zip/entry.rb +7 -0
  56. data/lib/omnizip.rb +1 -1
  57. metadata +4 -6
  58. data/lib/omnizip/filters/filter_base.rb +0 -6
  59. data/lib/omnizip/filters/registration.rb +0 -22
  60. data/lib/omnizip/filters/registry.rb +0 -111
  61. data/lib/omnizip/format_registry.rb +0 -100
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e86ca6410983afcc2259af21021ae0049d2b5f4def32975d9fa1568297417e3
4
- data.tar.gz: b52224b6ef3a5b2dab3f56c9117daf36b679ecda95983cafd62ddd7d7f05b35a
3
+ metadata.gz: 3d76166f4e6d65cb67526c079369395377bc4d30af75d52b9d83374f99721071
4
+ data.tar.gz: c47f5c274906ca6d92293606add01a44bfdb4e3f2f499647608bd2ac0629b98f
5
5
  SHA512:
6
- metadata.gz: 3b74c21559d4c813b83c82d80957c97d3f57f0d512cdb1895a92f869bd27594f5c0b60ae108179431e50f52bb44bfbb795343facb2de8f853258e483f4b63e75
7
- data.tar.gz: ff4f463c54686edc825f514bb74c527d33a0a9319e2952ac628984392eb5acfb26ce77077a12ae711ddb44a419361a93e3336ae43d8c85a23d01e3efd445a029
6
+ metadata.gz: 4cc7cbf7d9ce6763e6648abc3415b588a5a79df8e6b15fdfea5a6db962531b7c584628c1fe1b2c5c604d4113d05f9120bd8eb61a1fba70acdbfa324b3e621a2f
7
+ data.tar.gz: b796a58122e8d1b9ce208aafbf2b64826789e34fd8d165f05bab54ebd74b9169bdb1814bb8f83f2209bc09abad465a5b5b73c12be8570e3b2429a3288119563f
@@ -23,6 +23,8 @@ module Omnizip
23
23
  # the required methods. Algorithms are automatically registered with the
24
24
  # AlgorithmRegistry when defined.
25
25
  class Algorithm
26
+ require "stringio"
27
+
26
28
  attr_reader :options, :filter
27
29
 
28
30
  # Initialize algorithm with options.
@@ -38,7 +40,7 @@ module Omnizip
38
40
  # The filter will be applied before compression and reversed after
39
41
  # decompression. Returns self for method chaining.
40
42
  #
41
- # @param filter [Filters::FilterBase, FilterPipeline] Filter or
43
+ # @param filter [Omnizip::Filter, FilterPipeline] Filter or
42
44
  # pipeline to use
43
45
  # @return [self] For method chaining
44
46
  def with_filter(filter)
@@ -82,6 +84,39 @@ module Omnizip
82
84
  "#{self} must implement .metadata"
83
85
  end
84
86
 
87
+ # Class-level convenience: compress `data` and return the
88
+ # compressed bytes. Carries the algorithm's streaming contract
89
+ # over a single StringIO so callers with the whole payload in
90
+ # memory (parallel compressors, small files) don't need to
91
+ # instantiate and wire streams themselves.
92
+ #
93
+ # @param data [String, IO] Input to compress
94
+ # @param options [Hash] Forwarded to the algorithm
95
+ # @return [String] Compressed bytes
96
+ def compress(data, **options)
97
+ instance = new(options)
98
+ input = data.is_a?(::IO) ? data : ::StringIO.new(data.to_s.b)
99
+ output = ::StringIO.new
100
+ output.set_encoding(Encoding::BINARY)
101
+ instance.compress(input, output, options)
102
+ output.string
103
+ end
104
+
105
+ # Class-level convenience: decompress `data` and return the
106
+ # uncompressed bytes. Mirror of +.compress+.
107
+ #
108
+ # @param data [String, IO] Input to decompress
109
+ # @param options [Hash] Forwarded to the algorithm
110
+ # @return [String] Decompressed bytes
111
+ def decompress(data, **options)
112
+ instance = new(options)
113
+ input = data.is_a?(::IO) ? data : ::StringIO.new(data.to_s.b)
114
+ output = ::StringIO.new
115
+ output.set_encoding(Encoding::BINARY)
116
+ instance.decompress(input, output, options)
117
+ output.string
118
+ end
119
+
85
120
  # Automatically register algorithm when inherited.
86
121
  #
87
122
  # This hook is called whenever a class inherits from Algorithm,
@@ -82,9 +82,7 @@ module Omnizip
82
82
  # @param options [Models::CompressionOptions] Decompression options
83
83
  # @return [void]
84
84
  def decompress(input_stream, output_stream, _options = nil)
85
- if output_stream.respond_to?(:set_encoding)
86
- output_stream.set_encoding(Encoding::BINARY)
87
- end
85
+ output_stream.set_encoding(Encoding::BINARY)
88
86
  decoder = Decoder.new(input_stream)
89
87
  decompressed = decoder.decode_stream
90
88
  output_stream.write(decompressed)
@@ -77,9 +77,7 @@ module Omnizip
77
77
  # @param options [Models::CompressionOptions] Decompression options
78
78
  # @return [void]
79
79
  def decompress(input_stream, output_stream, _options = nil)
80
- if output_stream.respond_to?(:set_encoding)
81
- output_stream.set_encoding(Encoding::BINARY)
82
- end
80
+ output_stream.set_encoding(Encoding::BINARY)
83
81
  decoder = Decoder.new(input_stream)
84
82
  decompressed = decoder.decode_stream
85
83
  output_stream.write(decompressed)
@@ -73,8 +73,8 @@ module Omnizip
73
73
  return if compressed.nil? || compressed.empty?
74
74
 
75
75
  # Set output to binary mode if it's a StringIO
76
- output.set_encoding(Encoding::BINARY) if output.respond_to?(:set_encoding)
77
- output.binmode if output.respond_to?(:binmode)
76
+ output.set_encoding(Encoding::BINARY)
77
+ output.binmode
78
78
 
79
79
  # Use Zlib::Inflate with maximum window size
80
80
  inflater = Zlib::Inflate.new(Zlib::MAX_WBITS)
@@ -136,7 +136,7 @@ module Omnizip
136
136
  # @return [IO] The output_stream (for chaining)
137
137
  def decompress(input_stream, output_stream, options = nil)
138
138
  # Set binary encoding on output stream for proper byte handling
139
- output_stream.set_encoding(Encoding::BINARY) if output_stream.respond_to?(:set_encoding)
139
+ output_stream.set_encoding(Encoding::BINARY)
140
140
 
141
141
  # Build decoder options, merging with instance variables as fallbacks
142
142
  decoder_opts = build_decoder_options(options)
@@ -83,23 +83,19 @@ module Omnizip
83
83
  )
84
84
 
85
85
  # Read input
86
- input_data = input.respond_to?(:read) ? input.read : input
86
+ input_data = Omnizip::IO::Source.for(input).read
87
87
 
88
88
  # Encode with LZMA2
89
89
  compressed = encoder.encode(input_data)
90
90
 
91
91
  # Write to output
92
- if output.respond_to?(:write)
93
- output.write(compressed)
94
- else
95
- output.replace(compressed)
96
- end
92
+ Omnizip::IO::Sink.for(output).write(compressed)
97
93
  end
98
94
 
99
95
  # Decompress LZMA2 data
100
96
  def decompress(input, output, options = {})
101
97
  # Read input data
102
- input_data = input.respond_to?(:read) ? input.read : input
98
+ input_data = Omnizip::IO::Source.for(input).read
103
99
  input_stream = StringIO.new(input_data)
104
100
  input_stream.set_encoding(Encoding::BINARY)
105
101
 
@@ -120,11 +116,7 @@ module Omnizip
120
116
  decompressed = decoder.decode_stream
121
117
 
122
118
  # Write to output
123
- if output.respond_to?(:write)
124
- output.write(decompressed)
125
- else
126
- output.replace(decompressed)
127
- end
119
+ Omnizip::IO::Sink.for(output).write(decompressed)
128
120
  end
129
121
 
130
122
  # Encode dictionary size as single byte for LZMA2 properties
@@ -96,9 +96,7 @@ module Omnizip
96
96
  # @param options [Models::CompressionOptions] Decompression options
97
97
  # @return [void]
98
98
  def decompress(input_stream, output_stream, _options = nil)
99
- if output_stream.respond_to?(:set_encoding)
100
- output_stream.set_encoding(Encoding::BINARY)
101
- end
99
+ output_stream.set_encoding(Encoding::BINARY)
102
100
  decoder = Decoder.new(input_stream)
103
101
  decompressed = decoder.decode_stream
104
102
  output_stream.write(decompressed)
@@ -1,7 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Omnizip
4
- # Compression algorithm implementations
4
+ # High-level compression algorithm facades.
5
+ #
6
+ # Each top-level constant in this namespace (Deflate, BZip2, LZMA,
7
+ # LZMA2, Zstandard, PPMd7, PPMd8) is a facade that exposes the
8
+ # streaming +.compress+/+.decompress+ contract from +Omnizip::Algorithm+.
9
+ # Format-specific readers/writers call these facades for the actual
10
+ # compression work; the facades themselves do not know about archive
11
+ # container structure.
12
+ #
13
+ # Bit-level SDK ports (state machines, range coders, match finders)
14
+ # live under +Omnizip::Implementations+, not here. This namespace
15
+ # owns the *streaming contract*; that namespace owns the *primitives*.
16
+ # The boundary is: +Algorithms+ calls +Implementations+, never the
17
+ # reverse.
5
18
  module Algorithms
6
19
  autoload :PPMdBase, "omnizip/algorithms/ppmd_base"
7
20
  autoload :LZMA2Const, "omnizip/algorithms/lzma2/constants"
@@ -185,29 +185,31 @@ module Omnizip
185
185
  end
186
186
  end
187
187
 
188
- # Helper methods to handle different entry types
188
+ # Helper methods to handle different entry types. Each delegates
189
+ # to the Omnizip::Entry contract; format-specific accessors stay
190
+ # on the format entry classes themselves.
189
191
  def entry_name(entry)
190
- entry.respond_to?(:name) ? entry.name : entry.to_s
192
+ entry.entry_name || entry.to_s
191
193
  end
192
194
 
193
195
  def entry_directory?(entry)
194
- entry.respond_to?(:directory?) && entry.directory?
196
+ entry.entry_directory?
195
197
  end
196
198
 
197
199
  def entry_size(entry)
198
- entry.respond_to?(:size) ? entry.size : 0
200
+ entry.entry_size || 0
199
201
  end
200
202
 
201
203
  def entry_compressed_size(entry)
202
- entry.respond_to?(:compressed_size) ? entry.compressed_size : nil
204
+ entry.compressed_size if entry.is_a?(Omnizip::Formats::SevenZip::Models::FileEntry)
203
205
  end
204
206
 
205
207
  def entry_has_stream?(entry)
206
- entry.respond_to?(:has_stream?) ? entry.has_stream? : true
208
+ entry.has_stream? if entry.is_a?(Omnizip::Formats::SevenZip::Models::FileEntry)
207
209
  end
208
210
 
209
211
  def entry_mtime(entry)
210
- entry.respond_to?(:mtime) ? entry.mtime : nil
212
+ entry.entry_mtime
211
213
  end
212
214
  end
213
215
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omnizip
4
+ # Mix-in that establishes the common contract every archive entry
5
+ # satisfies, regardless of format.
6
+ #
7
+ # Each format-specific entry class (Zip::Entry, Tar::Entry,
8
+ # SevenZip::Models::FileEntry, Iso::DirectoryRecord, Ole::Dirent,
9
+ # Xar::Entry, Rpm::Entry, Msi::Entry, Cpio::Entry, Rar3::Entry,
10
+ # Rar5::Entry, Xz::Entry, Metadata::EntryMetadata) includes this
11
+ # module so callers can rely on a single narrow interface instead
12
+ # of duck-typing through `respond_to?(:name) / :path / :filename`
13
+ # cascades.
14
+ #
15
+ # Including classes MUST override the four methods below. The
16
+ # defaults raise `NotImplementedError` to surface missing
17
+ # implementations at call time rather than at include time.
18
+ module Entry
19
+ # @return [String, nil] in-archive path, or nil if the entry has
20
+ # no name (e.g. empty anti-entry)
21
+ def entry_name
22
+ raise NotImplementedError,
23
+ "#{self.class} must implement #entry_name"
24
+ end
25
+
26
+ # @return [Boolean] true if the entry is a directory
27
+ def entry_directory?
28
+ raise NotImplementedError,
29
+ "#{self.class} must implement #entry_directory?"
30
+ end
31
+
32
+ # @return [Integer, nil] uncompressed size in bytes
33
+ def entry_size
34
+ raise NotImplementedError,
35
+ "#{self.class} must implement #entry_size"
36
+ end
37
+
38
+ # @return [Time, nil] modification time
39
+ def entry_mtime
40
+ raise NotImplementedError,
41
+ "#{self.class} must implement #entry_mtime"
42
+ end
43
+ end
44
+ end
@@ -184,18 +184,10 @@ module Omnizip
184
184
 
185
185
  # Get filename from entry
186
186
  #
187
- # @param entry [Object] Entry
187
+ # @param entry [#entry_name] Entry (Omnizip::Entry or compatible)
188
188
  # @return [String] Filename
189
189
  def entry_filename(entry)
190
- if entry.respond_to?(:name)
191
- entry.name
192
- elsif entry.respond_to?(:path)
193
- entry.path
194
- elsif entry.respond_to?(:filename)
195
- entry.filename
196
- else
197
- entry.to_s
198
- end
190
+ entry.entry_name || entry.to_s
199
191
  end
200
192
 
201
193
  # Update progress tracker
@@ -36,7 +36,7 @@ module Omnizip
36
36
  # Filters are applied in the order they are added during encoding,
37
37
  # and in reverse order during decoding.
38
38
  #
39
- # @param filter [Filters::FilterBase] Filter instance to add
39
+ # @param filter [Omnizip::Filter] Filter instance to add
40
40
  # @return [self] For method chaining
41
41
  def add_filter(filter)
42
42
  @filters << filter
@@ -4,16 +4,18 @@ module Omnizip
4
4
  class FilterRegistry < Omnizip::Registry
5
5
  DEFAULT_FORMATS = %i[xz seven_zip].freeze
6
6
 
7
+ # Single source of truth for builtin filters. Each entry binds the
8
+ # filter name to its class and the formats that support it.
7
9
  BUILTIN_FILTERS = {
8
- "bcj-x86": "Omnizip::Filters::BcjX86",
9
- "bcj-arm": "Omnizip::Filters::BcjArm",
10
- "bcj-arm64": "Omnizip::Filters::BcjArm64",
11
- "bcj-ia64": "Omnizip::Filters::BcjIa64",
12
- "bcj-ppc": "Omnizip::Filters::BcjPpc",
13
- "bcj-sparc": "Omnizip::Filters::BcjSparc",
14
- bcj: "Omnizip::Filters::BCJ",
15
- bcj2: "Omnizip::Filters::Bcj2",
16
- delta: "Omnizip::Filters::Delta",
10
+ "bcj-x86": { const: "Omnizip::Filters::BcjX86", formats: %i[xz seven_zip] },
11
+ "bcj-arm": { const: "Omnizip::Filters::BcjArm", formats: %i[xz seven_zip] },
12
+ "bcj-arm64": { const: "Omnizip::Filters::BcjArm64", formats: [:seven_zip] },
13
+ "bcj-ia64": { const: "Omnizip::Filters::BcjIa64", formats: %i[xz seven_zip] },
14
+ "bcj-ppc": { const: "Omnizip::Filters::BcjPpc", formats: %i[xz seven_zip] },
15
+ "bcj-sparc": { const: "Omnizip::Filters::BcjSparc", formats: %i[xz seven_zip] },
16
+ bcj: { const: "Omnizip::Filters::BCJ", formats: [:seven_zip] },
17
+ bcj2: { const: "Omnizip::Filters::Bcj2", formats: [:seven_zip] },
18
+ delta: { const: "Omnizip::Filters::Delta", formats: %i[xz seven_zip] },
17
19
  }.freeze
18
20
 
19
21
  class << self
@@ -86,7 +88,6 @@ module Omnizip
86
88
 
87
89
  trigger = lazy_triggers[normalized]
88
90
  if trigger
89
- synchronize { lazy_triggers.delete(normalized) }
90
91
  trigger.call
91
92
  entry = storage[normalized]
92
93
  return entry if entry
@@ -98,12 +99,13 @@ module Omnizip
98
99
  end
99
100
  end
100
101
 
101
- # Lazy triggers — calling the Filters::Registry.register_all re-runs
102
- # the registration of every builtin filter. Idempotent: register just
103
- # overwrites the storage entry. Survives reset! because the trigger
104
- # proc is held by FilterRegistry, not the storage.
105
- Omnizip::FilterRegistry::BUILTIN_FILTERS.each_key do |name|
102
+ # Lazy triggers — each trigger resolves the filter's class (firing
103
+ # autoload) and registers it with its declared formats. Idempotent:
104
+ # register overwrites the storage entry. Survives reset! because the
105
+ # trigger proc is held by FilterRegistry, not the storage.
106
+ Omnizip::FilterRegistry::BUILTIN_FILTERS.each do |name, spec|
106
107
  Omnizip::FilterRegistry.register_lazy(name) do
107
- Omnizip::Filters::Registry.register_all
108
+ klass = Object.const_get(spec[:const])
109
+ Omnizip::FilterRegistry.register(name, klass, formats: spec[:formats])
108
110
  end
109
111
  end
@@ -34,7 +34,7 @@ module Omnizip
34
34
  # NOTE: Currently only decoding (decompression) is implemented.
35
35
  # Encoding is extremely complex and will be added in a future version.
36
36
  # For compression use cases, the simpler BCJ-x86 filter is recommended.
37
- class Bcj2 < FilterBase
37
+ class Bcj2 < Omnizip::Filter
38
38
  # Encode is not currently supported for BCJ2.
39
39
  #
40
40
  # @param _data [String] Binary data to encode
@@ -28,7 +28,7 @@ module Omnizip
28
28
  # The filter improves compression by making branch targets
29
29
  # position-independent. The offset in ARM BL instructions is stored
30
30
  # as word offset (divided by 4), and is relative to PC+8.
31
- class BcjArm < FilterBase
31
+ class BcjArm < Omnizip::Filter
32
32
  # ARM BL (Branch and Link) opcode
33
33
  OPCODE_BL = 0xEB
34
34
 
@@ -27,7 +27,7 @@ module Omnizip
27
27
  #
28
28
  # The filter improves compression by making branch targets and
29
29
  # page-aligned addresses position-independent.
30
- class BcjArm64 < FilterBase
30
+ class BcjArm64 < Omnizip::Filter
31
31
  # B/BL instruction base opcode
32
32
  OPCODE_B_BL = 0x94000000
33
33
 
@@ -27,7 +27,7 @@ module Omnizip
27
27
  #
28
28
  # The filter improves compression by making branch targets
29
29
  # position-independent.
30
- class BcjIa64 < FilterBase
30
+ class BcjIa64 < Omnizip::Filter
31
31
  # Size of IA-64 instruction bundle (16 bytes, little-endian)
32
32
  BUNDLE_SIZE = 16
33
33
 
@@ -27,7 +27,7 @@ module Omnizip
27
27
  #
28
28
  # The filter improves compression by making branch targets
29
29
  # position-independent.
30
- class BcjPpc < FilterBase
30
+ class BcjPpc < Omnizip::Filter
31
31
  # PPC B/BL instruction base (0x48000000)
32
32
  OPCODE_BASE = 0x48000000
33
33
 
@@ -27,7 +27,7 @@ module Omnizip
27
27
  #
28
28
  # The filter improves compression by making branch targets
29
29
  # position-independent.
30
- class BcjSparc < FilterBase
30
+ class BcjSparc < Omnizip::Filter
31
31
  # Size of SPARC instruction (4 bytes, big-endian)
32
32
  INSTRUCTION_SIZE = 4
33
33
 
@@ -27,7 +27,7 @@ module Omnizip
27
27
  #
28
28
  # The filter is reversible and works on 5-byte boundaries (1-byte
29
29
  # opcode + 4-byte address).
30
- class BcjX86 < FilterBase
30
+ class BcjX86 < Omnizip::Filter
31
31
  # x86 CALL opcode
32
32
  OPCODE_CALL = 0xE8
33
33
 
@@ -3,7 +3,6 @@
3
3
  module Omnizip
4
4
  # Filter implementations for preprocessing data before compression
5
5
  module Filters
6
- autoload :FilterBase, "omnizip/filters/filter_base"
7
6
  autoload :BCJ, "omnizip/filters/bcj"
8
7
  autoload :BcjX86, "omnizip/filters/bcj_x86"
9
8
  autoload :Bcj2, "omnizip/filters/bcj2"
@@ -17,6 +16,5 @@ module Omnizip
17
16
  autoload :BcjSparc, "omnizip/filters/bcj_sparc"
18
17
  autoload :BcjIa64, "omnizip/filters/bcj_ia64"
19
18
  autoload :Delta, "omnizip/filters/delta"
20
- autoload :Registry, "omnizip/filters/registry"
21
19
  end
22
20
  end
@@ -112,12 +112,6 @@ module Omnizip
112
112
  output_io.write(decompressed_io.read)
113
113
  end
114
114
 
115
- # Register BZIP2 format when loaded
116
- def register!
117
- FormatRegistry.register(".bz2", Omnizip::Formats::Bzip2File)
118
- FormatRegistry.register(".bzip2", Omnizip::Formats::Bzip2File)
119
- end
120
-
121
115
  private
122
116
 
123
117
  # Write BZIP2 header
@@ -163,4 +157,3 @@ module Omnizip
163
157
  end
164
158
  end
165
159
  end
166
-
@@ -8,6 +8,7 @@ module Omnizip
8
8
  # Represents a file, directory, or special file in a CPIO archive.
9
9
  # Supports newc, CRC, and ODC formats.
10
10
  class Entry
11
+ include Omnizip::Entry
11
12
  include Omnizip::Formats::Cpio::Constants
12
13
 
13
14
  # @return [String] Magic number identifying format
@@ -58,6 +59,11 @@ module Omnizip
58
59
  # @return [String] File data
59
60
  attr_accessor :data
60
61
 
62
+ def entry_name = name
63
+ def entry_directory? = directory?
64
+ def entry_size = filesize
65
+ def entry_mtime = mtime
66
+
61
67
  # Initialize CPIO entry
62
68
  #
63
69
  # @param attributes [Hash] Entry attributes
@@ -126,13 +126,7 @@ module Omnizip
126
126
  }
127
127
  end
128
128
  end
129
-
130
- # Auto-register CPIO format when loaded
131
- def register!
132
- FormatRegistry.register(".cpio", Reader)
133
- end
134
129
  end
135
130
  end
136
131
  end
137
132
  end
138
-
@@ -127,12 +127,6 @@ module Omnizip
127
127
  metadata
128
128
  end
129
129
 
130
- # Register GZIP format when loaded
131
- def register!
132
- FormatRegistry.register(".gz", Omnizip::Formats::Gzip)
133
- FormatRegistry.register(".gzip", Omnizip::Formats::Gzip)
134
- end
135
-
136
130
  private
137
131
 
138
132
  # Write GZIP header
@@ -231,4 +225,3 @@ module Omnizip
231
225
  end
232
226
  end
233
227
  end
234
-
@@ -6,9 +6,16 @@ module Omnizip
6
6
  # ISO 9660 Directory Record
7
7
  # Represents a file or directory entry
8
8
  class DirectoryRecord
9
+ include Omnizip::Entry
10
+
9
11
  attr_accessor :full_path
10
12
  attr_reader :length, :extended_attr_length, :location, :data_length, :recording_date, :flags, :file_unit_size, :interleave_gap_size, :volume_sequence_number, :name, :system_use
11
13
 
14
+ def entry_name = full_path || name
15
+ def entry_directory? = directory?
16
+ def entry_size = data_length
17
+ def entry_mtime = recording_date
18
+
12
19
  # Set the full path for this record, used by Reader when walking
13
20
  # a directory tree. Allows callers to look up records by path
14
21
  # without re-joining parent names.
@@ -127,11 +127,6 @@ module Omnizip
127
127
 
128
128
  writer.write
129
129
  end
130
-
131
- # Auto-register ISO format when loaded
132
- def self.register!
133
- FormatRegistry.register(".iso", Reader)
134
- end
135
130
  end
136
131
  end
137
132
  end
@@ -132,12 +132,6 @@ module Omnizip
132
132
  }
133
133
  end
134
134
 
135
- # Register LZIP format when loaded
136
- def register!
137
- FormatRegistry.register(".lz", Omnizip::Formats::Lzip)
138
- FormatRegistry.register(".lzip", Omnizip::Formats::Lzip)
139
- end
140
-
141
135
  # Detect if data is LZIP format
142
136
  #
143
137
  # @param data [String] Data to check
@@ -149,4 +143,3 @@ module Omnizip
149
143
  end
150
144
  end
151
145
  end
152
-
@@ -138,13 +138,7 @@ module Omnizip
138
138
  uncompressed_size: decoder.uncompressed_size,
139
139
  }
140
140
  end
141
-
142
- # Register LZMA_Alone format when loaded
143
- def register!
144
- FormatRegistry.register(".lzma", Omnizip::Formats::LzmaAlone)
145
- end
146
141
  end
147
142
  end
148
143
  end
149
144
  end
150
-
@@ -8,8 +8,14 @@ module Omnizip
8
8
  # Represents a single file within an MSI package.
9
9
  # File information is assembled from File, Component, and Directory tables.
10
10
  class Entry
11
+ include Omnizip::Entry
11
12
  include Omnizip::Formats::Msi::Constants
12
13
 
14
+ def entry_name = path
15
+ def entry_directory? = false
16
+ def entry_size = size
17
+ def entry_mtime = nil
18
+
13
19
  # @return [String] Full installation path
14
20
  attr_accessor :path
15
21
 
@@ -67,16 +67,7 @@ module Omnizip
67
67
  def info(path)
68
68
  open(path, &:info)
69
69
  end
70
-
71
- # Register MSI format with format registry
72
- #
73
- # This overrides OLE's .msi registration.
74
- def register!
75
- FormatRegistry.register(".msi", self)
76
- FormatRegistry.register(".msp", self)
77
- end
78
70
  end
79
71
  end
80
72
  end
81
73
  end
82
-
@@ -8,8 +8,14 @@ module Omnizip
8
8
  # Represents a file or directory entry in an OLE compound document.
9
9
  # Each dirent is 128 bytes and contains metadata about the entry.
10
10
  class Dirent
11
+ include Omnizip::Entry
11
12
  include Omnizip::Formats::Ole::Constants
12
13
 
14
+ def entry_name = name
15
+ def entry_directory? = dir?
16
+ def entry_size = nil
17
+ def entry_mtime = modify_time
18
+
13
19
  # Pack format for dirent structure
14
20
  PACK = "a64 v C C V3 a16 V a8 a8 V2 a4"
15
21
 
@@ -117,14 +117,6 @@ module Omnizip
117
117
  end
118
118
  end
119
119
 
120
- # Register OLE format in registry
121
- def register!
122
- FormatRegistry.register(".ole", Storage)
123
- FormatRegistry.register(".doc", Storage)
124
- FormatRegistry.register(".xls", Storage)
125
- FormatRegistry.register(".ppt", Storage)
126
- end
127
-
128
120
  private
129
121
 
130
122
  # Recursively extract dirent to directory
@@ -147,4 +139,3 @@ module Omnizip
147
139
  end
148
140
  end
149
141
  end
150
-