Class: Zip::ZipExtraField::IUnix

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

Overview

Info-ZIP Extra for UNIX uid/gid

Constant Summary

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

- (IUnix) initialize(binstr = nil)

A new instance of IUnix



1728
1729
1730
1731
1732
# File 'lib/zip/zip.rb', line 1728

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

Instance Attribute Details

- (Object) gid

Returns the value of attribute gid



1733
1734
1735
# File 'lib/zip/zip.rb', line 1733

def gid
  @gid
end

- (Object) uid

Returns the value of attribute uid



1733
1734
1735
# File 'lib/zip/zip.rb', line 1733

def uid
  @uid
end

Instance Method Details

- (Object) ==(other)



1745
1746
1747
1748
# File 'lib/zip/zip.rb', line 1745

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

- (Object) merge(binstr)



1735
1736
1737
1738
1739
1740
1741
1742
1743
# File 'lib/zip/zip.rb', line 1735

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

- (Object) pack_for_c_dir



1754
1755
1756
# File 'lib/zip/zip.rb', line 1754

def pack_for_c_dir
  ""
end

- (Object) pack_for_local



1750
1751
1752
# File 'lib/zip/zip.rb', line 1750

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