class Zip::ExtraField::UniversalTime
Info-ZIP Additional timestamp field
Constants
- ATIME_MASK
- CTIME_MASK
- HEADER_ID
- MTIME_MASK
Attributes
atime[R]
ctime[R]
flag[R]
mtime[R]
Public Class Methods
new(binstr = nil)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 11 def initialize(binstr = nil) @ctime = nil @mtime = nil @atime = nil @flag = 0 merge(binstr) unless binstr.nil? end
Public Instance Methods
==(other)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 57 def ==(other) @mtime == other.mtime && @atime == other.atime && @ctime == other.ctime end
atime=(time)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 22 def atime=(time) @flag = time.nil? ? @flag & ~ATIME_MASK : @flag | ATIME_MASK @atime = time end
ctime=(time)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 27 def ctime=(time) @flag = time.nil? ? @flag & ~CTIME_MASK : @flag | CTIME_MASK @ctime = time end
merge(binstr)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 37 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) return if !size || size <= 0 @flag, *times = content.unpack('Cl<l<l<') # Parse the timestamps, in order, based on which flags are set. return if times[0].nil? @mtime ||= ::Zip::DOSTime.at(times.shift) unless @flag & MTIME_MASK == 0 return if times[0].nil? @atime ||= ::Zip::DOSTime.at(times.shift) unless @flag & ATIME_MASK == 0 return if times[0].nil? @ctime ||= ::Zip::DOSTime.at(times.shift) unless @flag & CTIME_MASK == 0 end
mtime=(time)
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 32 def mtime=(time) @flag = time.nil? ? @flag & ~MTIME_MASK : @flag | MTIME_MASK @mtime = time end
pack_for_c_dir()
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 71 def pack_for_c_dir s = [@flag].pack('C') s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0 s end
pack_for_local()
click to toggle source
# File lib/zip/extra_field/universal_time.rb, line 63 def pack_for_local s = [@flag].pack('C') s << [@mtime.to_i].pack('l<') unless @flag & MTIME_MASK == 0 s << [@atime.to_i].pack('l<') unless @flag & ATIME_MASK == 0 s << [@ctime.to_i].pack('l<') unless @flag & CTIME_MASK == 0 s end