Module: DooDah::ZipEntryHeader

Includes:
ZipHeader
Included in:
CentralDirectoryHeader, LocalDirectoryHeader
Defined in:
lib/doo_dah/zip_header.rb

Constant Summary collapse

STORED =
0
DEFLATED =
8
LOCAL_ENTRY_HEADER_SIGNATURE =
0x04034b50
CENTRAL_ENTRY_HEADER_SIGNATURE =
0x02014b50
END_CENTRAL_DIRECTORY_SIGNATURE =
0x06054b50
LOCAL_ENTRY_FOOTER_SIGNATURE =
0x08074b50
LOCAL_ENTRY_STATIC_HEADER_LENGTH =
30
LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH =
4+4+4
VERSION_NEEDED_TO_EXTRACT =
10
GP_FLAGS_CRC_UNKNOWN =
0x0008
GP_FLAGS_UTF8 =
0x0800

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ZipHeader

signature_size, #write_signature

Class Method Details

.common_header_sizeObject



52
53
54
# File 'lib/doo_dah/zip_header.rb', line 52

def self.common_header_size
  14 + 12
end

.name_size(name) ⇒ Object



56
57
58
# File 'lib/doo_dah/zip_header.rb', line 56

def self.name_size(name)
  name.bytesize
end

Instance Method Details

#write_common_headerObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/doo_dah/zip_header.rb', line 60

def write_common_header()
  flags = GP_FLAGS_UTF8
  flags |= GP_FLAGS_CRC_UNKNOWN if crc.zero?
  write([
    VERSION_NEEDED_TO_EXTRACT, # version needed to extract
    flags,
    STORED,
    last_modified_time,
    last_modified_date,
    crc,
    size,                      # compressed_size = size (stored)
    size,
    name ? name.bytesize : 0,
    0                          # extra length
  ].pack('vvvvvVVVvv'))
end

#write_infozip_utf8_nameObject



81
82
83
# File 'lib/doo_dah/zip_header.rb', line 81

def write_infozip_utf8_name
  [0x7075, name.size + 5, 1, file-name-crc].pack('vvCV')
end

#write_nameObject



77
78
79
# File 'lib/doo_dah/zip_header.rb', line 77

def write_name
  write name
end