Class: Zip::ZipExtraField::IUnix

Inherits:
Generic show all
Defined in:
lib/ruby_archive/handlers/rubyzip/zip/zip.rb

Overview

Info-ZIP Extra for UNIX uid/gid

Constant Summary collapse

HEADER_ID =
"Ux"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Generic

#initial_parse, name, register_map, #to_c_dir_bin, #to_local_bin

Constructor Details

#initialize(binstr = nil) ⇒ IUnix

Returns a new instance of IUnix.



1762
1763
1764
1765
1766
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1762

def initialize(binstr = nil)
  @uid = 0
  @gid = 0
  binstr and merge(binstr)
end

Instance Attribute Details

#gidObject

Returns the value of attribute gid.



1767
1768
1769
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1767

def gid
  @gid
end

#uidObject

Returns the value of attribute uid.



1767
1768
1769
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1767

def uid
  @uid
end

Instance Method Details

#==(other) ⇒ Object



1779
1780
1781
1782
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1779

def ==(other)
  @uid == other.uid &&
  @gid == other.gid
end

#merge(binstr) ⇒ Object



1769
1770
1771
1772
1773
1774
1775
1776
1777
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1769

def merge(binstr)
  binstr == "" and return
  size, content = initial_parse(binstr)
  # size: 0 for central direcotry. 4 for local header
  return if(! size || size == 0)
  uid, gid = content.unpack("vv")
  @uid ||= uid
  @gid ||= gid
end

#pack_for_c_dirObject



1788
1789
1790
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1788

def pack_for_c_dir
  ""
end

#pack_for_localObject



1784
1785
1786
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 1784

def pack_for_local
  [@uid, @gid].pack("vv")
end