Tidy up accessors in `Entry`.
Remove a load of accessors from the 'public' API by not documenting them, and remove access to `header_signature` completely. Also, `Entry#extra` has been created to allow extra fields to be set correctly after initialization.
This commit is contained in:
parent
e4ceedaa58
commit
156b0f3dee
|
@ -6,14 +6,14 @@ module Zip
|
||||||
# Language encoding flag (EFS) bit
|
# Language encoding flag (EFS) bit
|
||||||
EFS = 0b100000000000
|
EFS = 0b100000000000
|
||||||
|
|
||||||
attr_accessor :comment, :compressed_size, :crc, :extra,
|
attr_accessor :comment, :compressed_size, :follow_symlinks, :name,
|
||||||
:name, :size, :local_header_offset, :zipfile, :fstype, :external_file_attributes,
|
:restore_ownership, :restore_permissions, :restore_times,
|
||||||
:internal_file_attributes,
|
:size, :unix_gid, :unix_perms, :unix_uid, :zipfile
|
||||||
:gp_flags, :header_signature, :follow_symlinks,
|
|
||||||
:restore_times, :restore_permissions, :restore_ownership,
|
attr_accessor :crc, :dirty, :external_file_attributes, :fstype, :gp_flags,
|
||||||
:unix_uid, :unix_gid, :unix_perms,
|
:internal_file_attributes, :local_header_offset # :nodoc:
|
||||||
:dirty
|
|
||||||
attr_reader :compression_level, :ftype, :filepath # :nodoc:
|
attr_reader :extra, :compression_level, :ftype, :filepath # :nodoc:
|
||||||
|
|
||||||
def set_default_vars_values
|
def set_default_vars_values
|
||||||
@local_header_offset = 0
|
@local_header_offset = 0
|
||||||
|
@ -89,6 +89,14 @@ module Zip
|
||||||
gp_flags & 8 == 8
|
gp_flags & 8 == 8
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def extra=(field)
|
||||||
|
@extra = if field.nil?
|
||||||
|
ExtraField.new
|
||||||
|
else
|
||||||
|
field.kind_of?(ExtraField) ? field : ExtraField.new(field.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def time
|
def time
|
||||||
if @extra['UniversalTime']
|
if @extra['UniversalTime']
|
||||||
@extra['UniversalTime'].mtime
|
@extra['UniversalTime'].mtime
|
||||||
|
@ -384,7 +392,7 @@ module Zip
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_c_dir_entry_signature
|
def check_c_dir_entry_signature
|
||||||
return if header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
return if @header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
||||||
|
|
||||||
raise Error, "Zip local header magic not found at location '#{local_header_offset}'"
|
raise Error, "Zip local header magic not found at location '#{local_header_offset}'"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue