Class: FormatParser::ZIPParser::FileReader::ZipEntry
- Inherits:
-
Object
- Object
- FormatParser::ZIPParser::FileReader::ZipEntry
- Includes:
- AttributesJSON
- Defined in:
- lib/parsers/zip_parser/file_reader.rb
Overview
Represents a file within the ZIP archive being read
Constant Summary
Constants included from AttributesJSON
AttributesJSON::MAXIMUM_JSON_NESTING_WHEN_SANITIZING
Instance Attribute Summary collapse
-
#comment ⇒ String
The file comment.
-
#compressed_size ⇒ Fixnum
Size of compressed file data in the ZIP.
-
#crc32 ⇒ Fixnum
The CRC32 checksum of this file.
-
#disk_number_start ⇒ Fixnum
Disk number where this file starts.
-
#dos_date ⇒ Fixnum
The bit-packed DOS date.
-
#dos_time ⇒ Fixnum
The bit-packed DOS time.
-
#external_attrs ⇒ Fixnum
External attributes of the file.
-
#filename ⇒ String
The filename.
-
#gp_flags ⇒ Fixnum
Bit-packed general purpose flags.
-
#internal_attrs ⇒ Fixnum
Internal attributes of the file.
-
#local_file_header_offset ⇒ Fixnum
At what offset the local file header starts in your original IO object.
-
#made_by ⇒ Fixnum
Bit-packed version signature of the program that made the archive.
-
#storage_mode ⇒ Fixnum
Storage mode (0 for stored, 8 for deflate).
-
#uncompressed_size ⇒ Fixnum
Size of the file once uncompressed.
-
#version_needed_to_extract ⇒ Fixnum
ZIP version support needed to extract this file.
Instance Method Summary collapse
-
#compressed_data_offset ⇒ Fixnum
At what offset you should start reading for the compressed data in your original IO object.
-
#compressed_data_offset=(offset) ⇒ Object
Sets the offset at which the compressed data for this file starts in the ZIP.
-
#known_offset? ⇒ Boolean
Tells whether the compressed data offset is already known for this entry.
-
#uses_data_descriptor? ⇒ Boolean
Tells whether the entry uses a data descriptor (this is defined by bit 3 in the GP flags).
Methods included from AttributesJSON
_sanitize_json_value, #as_json, #to_json
Instance Attribute Details
#comment ⇒ String
Returns the file comment.
116 117 118 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 116 def comment @comment end |
#compressed_size ⇒ Fixnum
Returns size of compressed file data in the ZIP.
94 95 96 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 94 def compressed_size @compressed_size end |
#crc32 ⇒ Fixnum
Returns the CRC32 checksum of this file.
91 92 93 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 91 def crc32 @crc32 end |
#disk_number_start ⇒ Fixnum
Returns disk number where this file starts.
103 104 105 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 103 def disk_number_start @disk_number_start end |
#dos_date ⇒ Fixnum
Returns the bit-packed DOS date.
88 89 90 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 88 def dos_date @dos_date end |
#dos_time ⇒ Fixnum
Returns the bit-packed DOS time.
85 86 87 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 85 def dos_time @dos_time end |
#external_attrs ⇒ Fixnum
Returns external attributes of the file.
109 110 111 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 109 def external_attrs @external_attrs end |
#filename ⇒ String
Returns the filename.
100 101 102 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 100 def filename @filename end |
#gp_flags ⇒ Fixnum
Returns bit-packed general purpose flags.
79 80 81 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 79 def gp_flags @gp_flags end |
#internal_attrs ⇒ Fixnum
Returns internal attributes of the file.
106 107 108 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 106 def internal_attrs @internal_attrs end |
#local_file_header_offset ⇒ Fixnum
Returns at what offset the local file header starts in your original IO object.
113 114 115 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 113 def local_file_header_offset @local_file_header_offset end |
#made_by ⇒ Fixnum
Returns bit-packed version signature of the program that made the archive.
73 74 75 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 73 def made_by @made_by end |
#storage_mode ⇒ Fixnum
Returns Storage mode (0 for stored, 8 for deflate).
82 83 84 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 82 def storage_mode @storage_mode end |
#uncompressed_size ⇒ Fixnum
Returns size of the file once uncompressed.
97 98 99 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 97 def uncompressed_size @uncompressed_size end |
#version_needed_to_extract ⇒ Fixnum
Returns ZIP version support needed to extract this file.
76 77 78 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 76 def version_needed_to_extract @version_needed_to_extract end |
Instance Method Details
#compressed_data_offset ⇒ Fixnum
Returns at what offset you should start reading for the compressed data in your original IO object.
120 121 122 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 120 def compressed_data_offset @compressed_data_offset || raise(LocalHeaderPending) end |
#compressed_data_offset=(offset) ⇒ Object
Sets the offset at which the compressed data for this file starts in the ZIP. By default, the value will be set by the Reader for you. If you use delayed reading, you need to set it by using the ‘get_compressed_data_offset` on the Reader:
entry.compressed_data_offset = reader.get_compressed_data_offset(io: file,
local_file_header_offset: entry.local_header_offset)
142 143 144 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 142 def compressed_data_offset=(offset) @compressed_data_offset = offset.to_i end |
#known_offset? ⇒ Boolean
Tells whether the compressed data offset is already known for this entry
126 127 128 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 126 def known_offset? !@compressed_data_offset.nil? end |
#uses_data_descriptor? ⇒ Boolean
Tells whether the entry uses a data descriptor (this is defined by bit 3 in the GP flags).
132 133 134 |
# File 'lib/parsers/zip_parser/file_reader.rb', line 132 def uses_data_descriptor? (gp_flags & 0x0008) == 0x0008 end |