Sha256: 23b1d7fa73c8cc87e5c9edd0ef3f3d6f95ce150b50e963bee276e36afeec83d3

Contents?: true

Size: 984 Bytes

Versions: 69

Compression:

Stored size: 984 Bytes

Contents

module Zip
  # Olf Info-ZIP Extra for UNIX uid/gid and file timestampes
  class ExtraField::OldUnix < ExtraField::Generic
    HEADER_ID = 'UX'
    register_map

    def initialize(binstr = nil)
      @uid = 0
      @gid = 0
      @atime = nil
      @mtime = nil
      binstr && merge(binstr)
    end

    attr_accessor :uid, :gid, :atime, :mtime

    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
    end

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

    def pack_for_local
      [@atime, @mtime, @uid, @gid].pack('VVvv')
    end

    def pack_for_c_dir
      [@atime, @mtime].pack('VV')
    end
  end
end

Version data entries

69 entries across 55 versions & 6 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/rubyzip-2.2.0/lib/zip/extra_field/old_unix.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
rubyzip-2.2.0 lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.3/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rubyzip-1.2.1/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-1.3.0/lib/zip/extra_field/old_unix.rb
rubyzip-2.1.0 lib/zip/extra_field/old_unix.rb
tdiary-5.1.0 vendor/bundle/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/extra_field/old_unix.rb
rubyzip-2.0.0 lib/zip/extra_field/old_unix.rb
rubyzip-1.3.0 lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/lib/zip/extra_field/old_unix.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/lib/zip/extra_field/old_unix.rb