Module: Omnizip::Formats::Cpio
- Defined in:
- lib/omnizip/formats/cpio.rb,
lib/omnizip/formats/cpio/entry.rb,
lib/omnizip/formats/cpio/reader.rb,
lib/omnizip/formats/cpio/writer.rb,
lib/omnizip/formats/cpio/constants.rb,
lib/omnizip/formats/cpio/bounded_io.rb
Overview
CPIO archive format support
Provides read and write access to CPIO archives in multiple formats:
- newc (SVR4 new ASCII format) - Most common, used in initramfs
- CRC (newc with CRC checksums)
- ODC (Old portable ASCII format)
CPIO is commonly used for:
- Linux initramfs/initrd
- RPM package contents
- Unix system backups
Defined Under Namespace
Modules: Constants Classes: BoundedIO, Entry, Reader, Writer
Class Method Summary collapse
-
.create(path, format: :newc) {|writer| ... } ⇒ String
Create CPIO archive.
-
.extract(cpio_path, output_dir) ⇒ Object
Extract CPIO archive.
-
.info(path) ⇒ Hash
Get archive information.
-
.list(path) ⇒ Array<Entry>
List CPIO archive contents.
-
.open(path) {|reader| ... } ⇒ Reader
Open CPIO archive for reading.
-
.register! ⇒ Object
Auto-register CPIO format when loaded.
Class Method Details
.create(path, format: :newc) {|writer| ... } ⇒ String
Create CPIO archive
50 51 52 53 54 55 56 |
# File 'lib/omnizip/formats/cpio.rb', line 50 def create(path, format: :newc) writer = Writer.new(path, format: format) yield writer if block_given? writer.write end |
.extract(cpio_path, output_dir) ⇒ Object
Extract CPIO archive
99 100 101 102 103 |
# File 'lib/omnizip/formats/cpio.rb', line 99 def extract(cpio_path, output_dir) open(cpio_path) do |cpio| cpio.extract_all(output_dir) end end |
.info(path) ⇒ Hash
Get archive information
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/omnizip/formats/cpio.rb', line 114 def info(path) open(path) do |cpio| entries = cpio.list { format: cpio.format_name, format_type: cpio.format, entry_count: entries.size, file_count: entries.count(&:file?), directory_count: entries.count(&:directory?), symlink_count: entries.count(&:symlink?), total_size: entries.sum(&:filesize), } end end |
.list(path) ⇒ Array<Entry>
List CPIO archive contents
88 89 90 |
# File 'lib/omnizip/formats/cpio.rb', line 88 def list(path) open(path, &:list) end |
.open(path) {|reader| ... } ⇒ Reader
Open CPIO archive for reading
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/omnizip/formats/cpio.rb', line 69 def open(path) reader = Reader.new(path) reader.open if block_given? yield reader else reader end end |
.register! ⇒ Object
Auto-register CPIO format when loaded
131 132 133 |
# File 'lib/omnizip/formats/cpio.rb', line 131 def register! FormatRegistry.register(".cpio", Reader) end |