A header for a tar file
Fields in the tar header
Pack format for a tar header
Unpack format for a tar header
Creates a tar header from IO stream
# File rubygems/package/tar_header.rb, line 99 def self.from(stream) header = stream.read 512 empty = (header == "\0" * 512) fields = header.unpack UNPACK_FORMAT new :name => fields.shift, :mode => fields.shift.oct, :uid => fields.shift.oct, :gid => fields.shift.oct, :size => fields.shift.oct, :mtime => fields.shift.oct, :checksum => fields.shift.oct, :typeflag => fields.shift, :linkname => fields.shift, :magic => fields.shift, :version => fields.shift.oct, :uname => fields.shift, :gname => fields.shift, :devmajor => fields.shift.oct, :devminor => fields.shift.oct, :prefix => fields.shift, :empty => empty end
Creates a new TarHeader
using vals
# File rubygems/package/tar_header.rb, line 128 def initialize(vals) unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode] then raise ArgumentError, ":name, :size, :prefix and :mode required" end vals[:uid] ||= 0 vals[:gid] ||= 0 vals[:mtime] ||= 0 vals[:checksum] ||= "" vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? vals[:magic] ||= "ustar" vals[:version] ||= "00" vals[:uname] ||= "wheel" vals[:gname] ||= "wheel" vals[:devmajor] ||= 0 vals[:devminor] ||= 0 FIELDS.each do |name| instance_variable_set "@#{name}", vals[name] end @empty = vals[:empty] end