Class: HttpZip::Parser::CentralDirectory
- Inherits:
-
Object
- Object
- HttpZip::Parser::CentralDirectory
- Defined in:
- lib/http_zip/parser/central_directory.rb
Overview
Parses the End Of Central Directory (EOCD) block of a zip file.
Constant Summary collapse
- EOCD_BLOCK_IDENTIFIER =
"\x50\x4B\x05\x06"
- EOCD64_LOCATOR_BLOCK_IDENTIFER =
"\x50\x4b\x06\x07"
- EOCD64_BLOCK_IDENTIFER =
"\x50\x4b\x06\x06"
Instance Attribute Summary collapse
-
#eocd64_offset ⇒ Object
readonly
Returns the value of attribute eocd64_offset.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(end_of_central_directory_bytes) ⇒ CentralDirectory
constructor
Create a new instance of CentralDirectory.
-
#parse_eocd64!(eocd64_block) ⇒ Object
Read the size and offset of the central directory from a Zip64 EOCD block.
Constructor Details
#initialize(end_of_central_directory_bytes) ⇒ CentralDirectory
Create a new instance of CentralDirectory.
16 17 18 19 20 |
# File 'lib/http_zip/parser/central_directory.rb', line 16 def initialize(end_of_central_directory_bytes) @bytes = end_of_central_directory_bytes parse! end |
Instance Attribute Details
#eocd64_offset ⇒ Object (readonly)
Returns the value of attribute eocd64_offset.
11 12 13 |
# File 'lib/http_zip/parser/central_directory.rb', line 11 def eocd64_offset @eocd64_offset end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
11 12 13 |
# File 'lib/http_zip/parser/central_directory.rb', line 11 def offset @offset end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
11 12 13 |
# File 'lib/http_zip/parser/central_directory.rb', line 11 def size @size end |
Instance Method Details
#parse_eocd64!(eocd64_block) ⇒ Object
Read the size and offset of the central directory from a Zip64 EOCD block.
26 27 28 29 30 31 32 |
# File 'lib/http_zip/parser/central_directory.rb', line 26 def parse_eocd64!(eocd64_block) unless eocd64_block.start_with?(EOCD64_BLOCK_IDENTIFER) raise ZipError, "EOCD64 record not found" end @size, @offset = eocd64_block[40..-1].unpack("Q<Q<") end |