class CPIO::ArchiveEntry
Constants
- ExecutableMask
- S_IFDIR
- S_IFMT
- S_IFREG
- TrailerMagic
Attributes
data[R]
filename[R]
Public Class Methods
from(io)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 127 def self.from(io) header = ArchiveHeader.from(io) filename = read_filename(header, io) data = read_data(header, io) new(header, filename, data) end
new(header, filename, data)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 152 def initialize(header, filename, data) @header = header @filename = filename @data = data end
new_directory(opts)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 134 def self.new_directory(opts) mode = S_IFDIR | opts[:mode] header = ArchiveHeader.with_defaults(:mode => mode, :name => opts[:name], :filesize => 0) new(header, opts[:name], '') end
new_file(opts)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 140 def self.new_file(opts) mode = S_IFREG | opts[:mode] header = ArchiveHeader.with_defaults(:mode => mode, :name => opts[:name], :filesize => opts[:io].size) opts[:io].rewind new(header, opts[:name], opts[:io].read) end
new_trailer()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 147 def self.new_trailer header = ArchiveHeader.with_defaults(:mode => S_IFREG, :name => TrailerMagic, :filesize => 0) new(header, TrailerMagic, '') end
Private Class Methods
read_data(header, io)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 192 def self.read_data(header, io) data = io.read(header.filesize) if data.size != header.filesize raise ArchiveFormatError, "Archive header seems to inaccurately contain length of the entry" end data end
read_filename(header, io)
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 184 def self.read_filename(header, io) fname = io.read(header.namesize) if fname.size != header.namesize raise ArchiveFormatError, "Archive header seems to innacurately contain length of filename" end fname.chomp("\000") end
Public Instance Methods
directory?()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 162 def directory? mode & S_IFMT == S_IFDIR end
executable?()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 170 def executable? (mode & ExecutableMask) != 0 end
file?()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 166 def file? mode & S_IFMT == S_IFREG end
mode()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 174 def mode @mode ||= sprintf('%o', @header.mode).to_s.oct end
to_data()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 178 def to_data sprintf("%s%s\000%s", @header.to_data, filename, data) end
trailer?()
click to toggle source
# File lib/excavate/extractors/cpio/cpio_old_format.rb, line 158 def trailer? @filename == TrailerMagic && @data.size == 0 end