class
ZipTricks::Streamer
- ZipTricks::Streamer
- Reference
- Object
Defined in:
streamer.crConstant Summary
-
DEFLATED =
8 -
STORED =
0
Constructors
Class Method Summary
Instance Method Summary
- #add_deflated(filename : String, modification_time : Time = Time.utc, unix_permissions : Int | Nil = nil, &)
-
#add_deflated_entry(filename : String, modification_time : Time = Time.utc, compressed_size : Int = 0, uncompressed_size : Int = 0, crc32 : Int = 0, unix_permissions : Int | Nil = nil, use_data_descriptor : Bool = false)
Writes out the local header for an entry (file in the ZIP) that is using the deflated storage model (is compressed).
-
#add_empty_directory(dirname : String, modification_time : Time = Time.utc, unix_permissions : Int | Nil = nil)
Adds an empty directory to the archive with a size of 0 and permissions of 755.
- #add_stored(filename : String, modification_time : Time = Time.utc, unix_permissions : Int | Nil = nil, &)
-
#add_stored_entry(filename : String, modification_time : Time = Time.utc, size : Int = 0, crc32 : Int = 0, unix_permissions : Int | Nil = nil, use_data_descriptor : Bool = false)
Writes out the local header for an entry (file in the ZIP) that is using the stored storage model (is stored as-is).
-
#advance(by)
Legacy method - use simulate_write instead for clarity
- #bytesize
- #finish
-
#simulate_write(num_bytes : Int)
Advances the internal IO pointer to keep the offsets of the ZIP file in check.
-
#update_last_entry_and_write_data_descriptor(crc32 : Int, compressed_size : Int, uncompressed_size : Int)
Updates the last entry written with the CRC32 checksum and compressed/uncompressed sizes.
- #write_central_directory
- #write_data_descriptor_for_last_entry
- #write_local_entry_header(entry)
Constructor Detail
Class Method Detail
Instance Method Detail
Writes out the local header for an entry (file in the ZIP) that is using the deflated storage model (is compressed). Once this method is called, you need to write the actual compressed contents and then call simulate_write with the number of bytes written.
Note that the deflated body that is going to be written into the output has to be precompressed (pre-deflated) before writing it into the Streamer, because otherwise it is impossible to know it's size upfront.
@param filename the name of the file in the entry @param modification_time the modification time of the file in the archive @param compressed_size the size of the compressed entry @param uncompressed_size the size of the entry when uncompressed, in bytes @param crc32 the CRC32 checksum of the entry when uncompressed @param unix_permissions which UNIX permissions to set, or nil for the default @param use_data_descriptor whether the entry body will be followed by a data descriptor @return the offset the output IO is at after writing the entry header
Adds an empty directory to the archive with a size of 0 and permissions of 755.
@param dirname the name of the directory in the archive @param modification_time the modification time of the directory in the archive @param unix_permissions which UNIX permissions to set, or nil for the default (0o755) @return the offset the output IO is at after writing the entry header
Writes out the local header for an entry (file in the ZIP) that is using the stored storage model (is stored as-is). Once this method is called, you need to write the actual contents of the body and then call simulate_write with the number of bytes written.
@param filename the name of the file in the entry @param modification_time the modification time of the file in the archive @param size the size of the file when uncompressed, in bytes @param crc32 the CRC32 checksum of the entry when uncompressed @param unix_permissions which UNIX permissions to set, or nil for the default @param use_data_descriptor whether the entry body will be followed by a data descriptor @return the offset the output IO is at after writing the entry header
Advances the internal IO pointer to keep the offsets of the ZIP file in
check. Use this if you are going to use accelerated writes to the socket
(like the sendfile() call) after writing the headers, or if you
just need to figure out the size of the archive.
Returns the current position in the output stream / ZIP archive.
Updates the last entry written with the CRC32 checksum and compressed/uncompressed sizes. For stored entries, compressed_size and uncompressed_size are the same. After updating the entry will immediately write the data descriptor bytes to the output.
@param crc32 the CRC32 checksum of the entry when uncompressed @param compressed_size the size of the compressed segment within the ZIP @param uncompressed_size the size of the entry once uncompressed @return the offset the output IO is at after writing the data descriptor