Class: Zip::ExtraField::NTFS
- Defined in:
- lib/zip/extra_field/ntfs.rb
Overview
PKWARE NTFS Extra Field (0x000a) Only Tag 0x0001 is supported
Constant Summary collapse
- HEADER_ID =
[0x000A].pack('v')
- WINDOWS_TICK =
10_000_000.0
- SEC_TO_UNIX_EPOCH =
11_644_473_600
Instance Attribute Summary collapse
-
#atime ⇒ Object
Returns the value of attribute atime.
-
#ctime ⇒ Object
Returns the value of attribute ctime.
-
#mtime ⇒ Object
Returns the value of attribute mtime.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(binstr = nil) ⇒ NTFS
constructor
A new instance of NTFS.
- #merge(binstr) ⇒ Object
-
#pack_for_c_dir ⇒ Object
But 7-zip for Windows only stores at central dir.
-
#pack_for_local ⇒ Object
Info-ZIP note states this extra field is stored at local header.
Methods inherited from Generic
#initial_parse, name, register_map, #to_c_dir_bin, #to_local_bin
Constructor Details
#initialize(binstr = nil) ⇒ NTFS
Returns a new instance of NTFS.
11 12 13 14 15 16 |
# File 'lib/zip/extra_field/ntfs.rb', line 11 def initialize(binstr = nil) @ctime = nil @mtime = nil @atime = nil binstr && merge(binstr) end |
Instance Attribute Details
#atime ⇒ Object
Returns the value of attribute atime.
18 19 20 |
# File 'lib/zip/extra_field/ntfs.rb', line 18 def atime @atime end |
#ctime ⇒ Object
Returns the value of attribute ctime.
18 19 20 |
# File 'lib/zip/extra_field/ntfs.rb', line 18 def ctime @ctime end |
#mtime ⇒ Object
Returns the value of attribute mtime.
18 19 20 |
# File 'lib/zip/extra_field/ntfs.rb', line 18 def mtime @mtime end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 39 40 |
# File 'lib/zip/extra_field/ntfs.rb', line 36 def ==(other) @mtime == other.mtime && @atime == other.atime && @ctime == other.ctime end |
#merge(binstr) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zip/extra_field/ntfs.rb', line 20 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) (size && content) || return content = content[4..-1] = (content) tag1 = [1] return unless tag1 ntfs_mtime, ntfs_atime, ntfs_ctime = tag1.unpack('Q<Q<Q<') ntfs_mtime && @mtime ||= from_ntfs_time(ntfs_mtime) ntfs_atime && @atime ||= from_ntfs_time(ntfs_atime) ntfs_ctime && @ctime ||= from_ntfs_time(ntfs_ctime) end |
#pack_for_c_dir ⇒ Object
But 7-zip for Windows only stores at central dir
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/zip/extra_field/ntfs.rb', line 48 def pack_for_c_dir # reserved 0 and tag 1 s = [0, 1].pack('Vv') tag1 = ''.force_encoding(Encoding::BINARY) if @mtime tag1 << [to_ntfs_time(@mtime)].pack('Q<') if @atime tag1 << [to_ntfs_time(@atime)].pack('Q<') tag1 << [to_ntfs_time(@ctime)].pack('Q<') if @ctime end end s << [tag1.bytesize].pack('v') << tag1 s end |
#pack_for_local ⇒ Object
Info-ZIP note states this extra field is stored at local header
43 44 45 |
# File 'lib/zip/extra_field/ntfs.rb', line 43 def pack_for_local pack_for_c_dir end |