/** * Constructor * * @param io.archive.zip.ZipArchiveWriter writer * @param io.archive.zip.ZipFileEntry file */ public function __construct(ZipArchiveWriter $writer, ZipFileEntry $file) { $this->writer = $writer; $this->file = $file; $this->data = NULL; $this->md = CRC32::digest(); }
/** * Constructor * * @param io.streams.OutputStream out * @param int level default 6 * @throws lang.IllegalArgumentException if the level is not between 0 and 9 */ public function __construct(OutputStream $out, $level = 6) { if ($level < 0 || $level > 9) { throw new IllegalArgumentException('Level ' . $level . ' out of range [0..9]'); } // Write GZIP format header: // * ID1, ID2 (Identification, \x1F, \x8B) // * CM (Compression Method, 8 = deflate) // * FLG (Flags, use 0) // * MTIME (Modification time, Un*x timestamp) // * XFL (Extra flags, 2 = compressor used maximum compression) // * OS (Operating system, 255 = unknown) $out->write(pack('CCCCVCC', 0x1f, 0x8b, 8, 0, time(), 2, 255)); // Now, convert stream to file handle and append deflating filter $this->out = Streams::writeableFd($out); if (!($this->filter = stream_filter_append($this->out, 'zlib.deflate', STREAM_FILTER_WRITE, $level))) { fclose($this->out); $this->out = NULL; throw new IOException('Could not append stream filter'); } $this->md = CRC32::digest(); }
/** * Creates a new message digest object * * @return security.checksum.MessageDigestImpl */ protected function newDigest() { return CRC32::digest(); }