Documention for: oneliner-gzip.r3 Created by: vincentecuye on: 30-Jan-2013 Last updated by: vincentecuye on: 30-Jan-2013 Format: text/editable Downloaded on: 30-Apr-2025 oneliner-gzip.r3 Author: Vincent Ecuyer Date: 30-Jan-2013 ===Purpose Creates gzip compatible archives. ===Limitations To keep the code short, a number of gzip files optional capabilities aren't implemented: *REBOL 3 only *No filename in archive (optional : gzip tools assumes the filename is the same as the source without the .gz extension) *No timestamp in archive (not a big problem with .tar archive, as tar and gzip are often used together) ===Usage gzip value (binary!) ===Example write %test.tar.gz gzip read/binary %test.tar ===Commented Code gzip: func [ "Compresses a binary and returns it in gzip format" value [binary!] "Data to compress" ][ ; In a gzip file, the last four bytes holds the data size, ; and the four bytes before holds the crc32. ; 'compress uses another crc method, ; so the crc bytes must be replaced ; replaces the crc by a crc32: head change at tail ; joins a gzip header to a 'compress stream, ; skipping the 'compress zlib header (2 bytes) join #{1F8B08000000000002FF} skip compress value 2 ; "at tail data -8" means at 8 bytes before the end of the data -8 ; builds a four bytes value with the crc-32 in little endian order ; ('to-binary on an integer! gives a 8 bytes result) reverse skip to-binary checksum/method value 'crc32 4 ]