Class: Omnizip::Formats::SevenZip::SplitArchiveWriter
- Inherits:
-
Object
- Object
- Omnizip::Formats::SevenZip::SplitArchiveWriter
- Includes:
- Constants
- Defined in:
- lib/omnizip/formats/seven_zip/split_archive_writer.rb
Overview
Split archive writer for .7z format Creates multi-volume archives with size limits
Defined Under Namespace
Classes: VolumeInfo
Constant Summary
Constants included from Constants
Constants::MAJOR_VERSION, Constants::MAX_NUM_BONDS, Constants::MAX_NUM_CODERS, Constants::MAX_NUM_PACK_STREAMS, Constants::MINOR_VERSION, Constants::SIGNATURE, Constants::SIGNATURE_SIZE, Constants::START_HEADER_SIZE
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#split_options ⇒ Object
readonly
Returns the value of attribute split_options.
-
#volumes ⇒ Object
readonly
Returns the value of attribute volumes.
Instance Method Summary collapse
-
#add_directory(dir_path, recursive: true) ⇒ Object
Add directory to archive.
-
#add_file(file_path, archive_path = nil) ⇒ Object
Add file to archive.
-
#add_files(pattern) ⇒ Object
Add files matching glob pattern.
-
#initialize(base_path, options = {}, split_options = nil) ⇒ SplitArchiveWriter
constructor
Initialize writer.
-
#write ⇒ Object
Write split archive.
Constructor Details
#initialize(base_path, options = {}, split_options = nil) ⇒ SplitArchiveWriter
Initialize writer
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 30 def initialize(base_path, = {}, = nil) @base_path = base_path @options = { algorithm: :lzma2, level: 5, solid: true, filters: [], }.merge() @split_options = || Models::SplitOptions.new @split_options.validate! @collector = FileCollector.new @entries = [] @volumes = [] @current_volume = nil @current_volume_number = 1 @global_offset = 0 end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 11 def base_path @base_path end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 11 def entries @entries end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 11 def @options end |
#split_options ⇒ Object (readonly)
Returns the value of attribute split_options.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 11 def @split_options end |
#volumes ⇒ Object (readonly)
Returns the value of attribute volumes.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 11 def volumes @volumes end |
Instance Method Details
#add_directory(dir_path, recursive: true) ⇒ Object
Add directory to archive
61 62 63 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 61 def add_directory(dir_path, recursive: true) @collector.add_path(dir_path, recursive: recursive) end |
#add_file(file_path, archive_path = nil) ⇒ Object
Add file to archive
52 53 54 55 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 52 def add_file(file_path, archive_path = nil) @collector.add_path(file_path, archive_path: archive_path, recursive: false) end |
#add_files(pattern) ⇒ Object
Add files matching glob pattern
68 69 70 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 68 def add_files(pattern) @collector.add_glob(pattern) end |
#write ⇒ Object
Write split archive
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/omnizip/formats/seven_zip/split_archive_writer.rb', line 75 def write # Collect files @entries = @collector.collect_files # Determine spanning strategy if @split_options.span_strategy == Omnizip::Models::SplitOptions::STRATEGY_BALANCED write_balanced else write_first_fit end end |