Class: HttpZip::Parser::CentralDirectoryFileHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/http_zip/parser/central_directory_file_header.rb

Overview

Parses the Central Directory File Header.

Constant Summary collapse

ZIP64_EXTRA_FIELD_HEADER_ID =
"\x01\x00"
CENTRAL_DIRECTORY_FILE_HEADER_IDENTIFIER =
"\x50\x4B\x01\x02"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_header_bytes) ⇒ CentralDirectoryFileHeader

Create a new instance of CentralDirectoryFileHeader.

Parameters:

  • file_header_bytes (String)

    the byte string of the file header



28
29
30
31
32
33
34
35
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 28

def initialize(file_header_bytes)
  @bytes = file_header_bytes
  unless @bytes.start_with?(CENTRAL_DIRECTORY_FILE_HEADER_IDENTIFIER)
    raise ZipError, "Central Directory File Header seems to be corrupt"
  end

  parse!
end

Instance Attribute Details

#compressed_sizeObject (readonly)

Returns the value of attribute compressed_size.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def compressed_size
  @compressed_size
end

#disk_numberObject (readonly)

Returns the value of attribute disk_number.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def disk_number
  @disk_number
end

#end_of_entryObject (readonly)

Returns the value of attribute end_of_entry.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def end_of_entry
  @end_of_entry
end

#external_file_attributesObject (readonly)

Returns the value of attribute external_file_attributes.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def external_file_attributes
  @external_file_attributes
end

#extra_field_lengthObject (readonly)

Returns the value of attribute extra_field_length.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def extra_field_length
  @extra_field_length
end

#file_comment_lengthObject (readonly)

Returns the value of attribute file_comment_length.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def file_comment_length
  @file_comment_length
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def file_name
  @file_name
end

#file_name_lengthObject (readonly)

Returns the value of attribute file_name_length.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def file_name_length
  @file_name_length
end

#header_offsetObject (readonly)

Returns the value of attribute header_offset.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def header_offset
  @header_offset
end

#internal_file_attributesObject (readonly)

Returns the value of attribute internal_file_attributes.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def internal_file_attributes
  @internal_file_attributes
end

#uncompressed_sizeObject (readonly)

Returns the value of attribute uncompressed_size.



10
11
12
# File 'lib/http_zip/parser/central_directory_file_header.rb', line 10

def uncompressed_size
  @uncompressed_size
end