![]() |
oneliner-gzip.r3Author: Vincent Ecuyer Contents:1. Purpose2. Limitations 3. Usage 4. Example 5. Commented Code 1. Purpose
2. Limitations
3. Usagegzip value (binary!) 4. Examplewrite %test.tar.gz gzip read/binary %test.tar 5. Commented Codegzip: 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 ] |
![]() | MakeDoc2 by REBOL - 30-Jan-2013 |