Class Zip::ZipExtraField
In: lib/zip/zip.rb
Parent: Hash

Methods

Classes and Modules

Class Zip::ZipExtraField::Generic
Class Zip::ZipExtraField::IUnix
Class Zip::ZipExtraField::UniversalTime

Constants

ID_MAP = {}

Public Class methods

start main of ZipExtraField < Hash

[Source]

# File lib/zip/zip.rb, line 1794
    def initialize(binstr = nil)
      binstr and merge(binstr)
    end

Public Instance methods

[Source]

# File lib/zip/zip.rb, line 1862
    def c_dir_length
      to_c_dir_bin.length
    end
c_dir_size()

Alias for c_dir_length

[Source]

# File lib/zip/zip.rb, line 1831
    def create(name)
      field_class = nil
      ID_MAP.each { |id, klass|
        if klass.name == name
          field_class = klass
          break
        end
      }
      if ! field_class
        raise ZipError, "Unknown extra field '#{name}'"
      end
      self[name] = field_class.new()
    end
length()

Alias for local_length

[Source]

# File lib/zip/zip.rb, line 1865
    def local_length
      to_local_bin.length
    end
local_size()

Alias for local_length

[Source]

# File lib/zip/zip.rb, line 1798
    def merge(binstr)
      binstr == "" and return
      i = 0 
      while i < binstr.length
        id = binstr[i,2]
        len = binstr[i+2,2].to_s.unpack("v")[0] 
        if id && ID_MAP.member?(id)
          field_name = ID_MAP[id].name
          if self.member?(field_name)
            self[field_name].mergea(binstr[i, len+4])
          else
            field_obj = ID_MAP[id].new(binstr[i, len+4])
            self[field_name] = field_obj
          end
        elsif id
          unless self["Unknown"]
            s = ""
            class << s
              alias_method :to_c_dir_bin, :to_s
              alias_method :to_local_bin, :to_s
            end
            self["Unknown"] = s
          end
          if ! len || len+4 > binstr[i..-1].length
            self["Unknown"] << binstr[i..-1]
            break;
          end
          self["Unknown"] << binstr[i, len+4]
        end
        i += len+4
      end
    end
size()

Alias for local_length

[Source]

# File lib/zip/zip.rb, line 1854
    def to_c_dir_bin
      s = ""
      each { |k, v|
        s << v.to_c_dir_bin
      }
      s
    end

[Source]

# File lib/zip/zip.rb, line 1845
    def to_local_bin
      s = ""
      each { |k, v|
        s << v.to_local_bin
      }
      s
    end
to_s()

Alias for to_local_bin

[Validate]