Archive::Zip::DataDescriptor is a convenience class which bundles important information concerning the compressed data in a ZIP archive entry and allows easy comparisons between instances of itself.
Create a new instance of this class where crc32, compressed_size, and uncompressed_size are all integers representing a CRC32 checksum of uncompressed data, the size of compressed data, and the size of uncompressed data respectively.
# File lib/archive/zip/data_descriptor.rb, line 11 def initialize(crc32, compressed_size, uncompressed_size) @crc32 = crc32 @compressed_size = compressed_size @uncompressed_size = uncompressed_size end
Writes the data wrapped in this object to io which must be a writable, IO-like object providing a write method. Returns the number of bytes written.
# File lib/archive/zip/data_descriptor.rb, line 47 def dump(io) io.write( [ crc32, compressed_size, uncompressed_size ].pack('VVV') ) end
Compares the crc32 and uncompressed_size attributes of this object with like-named attributes of other and raises Archive::Zip::Error for any mismatches.
NOTE: The compressed_size attribute is not checked because encrypted entries may have misleading compressed sizes. Checking only the CRC32 and uncompressed size of the data should be sufficient to ensure that an entry has been successfully extracted.
# File lib/archive/zip/data_descriptor.rb, line 33 def verify(other) unless crc32 == other.crc32 then raise Zip::Error, "CRC32 mismatch: #{crc32.to_s(16)} vs. #{other.crc32.to_s(16)}" end unless uncompressed_size == other.uncompressed_size then raise Zip::Error, "uncompressed size mismatch: #{uncompressed_size} vs. #{other.uncompressed_size}" end end
Generated with the Darkfish Rdoc Generator 2.