Class: Rant::Archive::Rubyzip::ZipExtraField::IUnix

Inherits:
Generic show all
Defined in:
lib/rant/archive/rubyzip.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.



1452
1453
1454
1455
1456
# File 'lib/rant/archive/rubyzip.rb', line 1452

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

Instance Attribute Details

#gidObject

Returns the value of attribute gid.



1457
1458
1459
# File 'lib/rant/archive/rubyzip.rb', line 1457

def gid
  @gid
end

#uidObject

Returns the value of attribute uid.



1457
1458
1459
# File 'lib/rant/archive/rubyzip.rb', line 1457

def uid
  @uid
end

Instance Method Details

#==(other) ⇒ Object



1469
1470
1471
1472
# File 'lib/rant/archive/rubyzip.rb', line 1469

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

#merge(binstr) ⇒ Object



1459
1460
1461
1462
1463
1464
1465
1466
1467
# File 'lib/rant/archive/rubyzip.rb', line 1459

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



1478
1479
1480
# File 'lib/rant/archive/rubyzip.rb', line 1478

def pack_for_c_dir
  ""
end

#pack_for_localObject



1474
1475
1476
# File 'lib/rant/archive/rubyzip.rb', line 1474

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