Class: Zip::ExtraField::OldUnix
- Defined in:
- lib/zip/extra_field/old_unix.rb
Overview
Olf Info-ZIP Extra for UNIX uid/gid and file timestampes
Constant Summary collapse
- HEADER_ID =
'UX'
Instance Attribute Summary collapse
-
#atime ⇒ Object
Returns the value of attribute atime.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(binstr = nil) ⇒ OldUnix
constructor
A new instance of OldUnix.
- #merge(binstr) ⇒ Object
- #pack_for_c_dir ⇒ Object
- #pack_for_local ⇒ Object
Methods inherited from Generic
#initial_parse, name, register_map, #to_c_dir_bin, #to_local_bin
Constructor Details
#initialize(binstr = nil) ⇒ OldUnix
Returns a new instance of OldUnix.
7 8 9 10 11 12 13 |
# File 'lib/zip/extra_field/old_unix.rb', line 7 def initialize(binstr = nil) @uid = 0 @gid = 0 @atime = nil @mtime = nil binstr && merge(binstr) end |
Instance Attribute Details
#atime ⇒ Object
Returns the value of attribute atime.
15 16 17 |
# File 'lib/zip/extra_field/old_unix.rb', line 15 def atime @atime end |
#gid ⇒ Object
Returns the value of attribute gid.
15 16 17 |
# File 'lib/zip/extra_field/old_unix.rb', line 15 def gid @gid end |
#mtime ⇒ Object
Returns the value of attribute mtime.
15 16 17 |
# File 'lib/zip/extra_field/old_unix.rb', line 15 def mtime @mtime end |
#uid ⇒ Object
Returns the value of attribute uid.
15 16 17 |
# File 'lib/zip/extra_field/old_unix.rb', line 15 def uid @uid end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/zip/extra_field/old_unix.rb', line 31 def ==(other) @uid == other.uid && @gid == other.gid && @atime == other.atime && @mtime == other.mtime end |
#merge(binstr) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zip/extra_field/old_unix.rb', line 17 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) # size: 0 for central directory. 4 for local header return if !size || size == 0 atime, mtime, uid, gid = content.unpack('VVvv') @uid ||= uid @gid ||= gid @atime ||= atime @mtime ||= mtime # rubocop:disable Naming/MemoizedInstanceVariableName end |
#pack_for_c_dir ⇒ Object
42 43 44 |
# File 'lib/zip/extra_field/old_unix.rb', line 42 def pack_for_c_dir [@atime, @mtime].pack('VV') end |
#pack_for_local ⇒ Object
38 39 40 |
# File 'lib/zip/extra_field/old_unix.rb', line 38 def pack_for_local [@atime, @mtime, @uid, @gid].pack('VVvv') end |