Lines Matching defs:file
20 protected $file = '';
33 * You can call this function before adding each file to set differen compression levels
34 * for each file.
49 * Open an existing ZIP file for reading
51 * @param string $file
54 public function open($file)
56 $this->file = $file;
57 $this->fh = @fopen($this->file, 'rb');
59 throw new ArchiveIOException('Could not open file for reading: '.$this->file);
70 * Reopen the file with open() again if you want to do additional operations
96 if ($this->closed || !$this->file) {
116 * found in the tar file, similar to the --strip-components feature of GNU tar. This is triggered when
136 if ($this->closed || !$this->file) {
146 $pos_entry = $cdir['offset']; // begin of the central file directory
149 // read file header
153 $pos_entry = ftell($this->fh); // position of the next file in central file directory
154 fseek($this->fh, $header['offset']); // seek to beginning of file header
181 // compressed files are written to temporary .gz file first
188 // open file for writing
191 throw new ArchiveIOException('Could not open file for writing: '.$extractto);
208 // read the file and store it on disk
218 // finalize compressed file
224 // close file
227 // unpack compressed file
232 throw new ArchiveIOException('Failed file extracting. gzip support missing?');
236 throw new ArchiveIOException('Could not open file for writing: '.$extractto);
249 unlink($extractto); // remove temporary gz file
264 * Create a new ZIP file
266 * If $file is empty, the zip file will be created in memory
268 * @param string $file
271 public function create($file = '')
273 $this->file = $file;
277 if ($this->file) {
278 $this->fh = @fopen($this->file, 'wb');
281 throw new ArchiveIOException('Could not open file for writing: '.$this->file);
290 * Add a file to the current ZIP archive using an existing file in the filesystem
292 * @param string $file path to the original file
298 * Add a file to the current archive using an existing file in the filesystem
300 * @param string $file path to the original file
305 public function addFile($file, $fileinfo = '')
308 $fileinfo = FileInfo::fromPath($file, $fileinfo);
315 $fp = @fopen($file, 'rb');
317 throw new ArchiveIOException('Could not open file for reading: '.$file);
324 // write local file header (temporary CRC and size)
372 // update the local file header with the computed CRC and size
383 // add info to central file directory
400 * Add a file to the current Zip archive using the given $data as content
403 * @param string $data binary content of the file to add
428 // write local file header
445 // add info to central file directory
462 * Add the closing footer to the archive if in write mode, close all file handles
490 $this->writebytes(pack('v', 0)); // .ZIP file comment length
495 // close file handles
496 if ($this->file) {
498 $this->file = '';
523 * let the library work on the new file directly.
525 * @param $file
528 public function save($file)
530 if (!@file_put_contents($file, $this->getArchive())) {
531 throw new ArchiveIOException('Could not write to file: '.$file);
538 * This key-value list contains general information about the ZIP file
544 $size = filesize($this->file);
584 * Read the next central file header
586 * Assumes the current file pointer is pointing at the right position
630 * Reads the local file header
632 * This header precedes each individual file inside the zip file. Assumes the current file pointer is pointing at
635 * @param array $header the central file header read previously (see above)
792 if (!$this->file) {
813 if (!$this->file) {
835 if ($this->file) {
896 * Returns a local file header for the given data
903 * @param string $name file name
915 $header = "\x50\x4b\x01\x02"; // central file header signature
926 ); // last mod file time and date
930 $header .= pack('v', strlen($name)); // file name length
932 $header .= pack('v', 0); // file comment length
934 $header .= pack('v', 0); // internal file attributes
935 $header .= pack('V', 0); // external file attributes @todo was 0x32!?
937 $header .= $name; // file name
944 * Returns a local file header for the given data
950 * @param string $name file name
962 $header = "\x50\x4b\x03\x04"; // local file header signature
972 ); // last mod file time and date
976 $header .= pack('v', strlen($name)); // file name length
978 $header .= $name; // file name
984 * Returns only a part of the local file header containing the CRC, size and compressed size.
1018 strlen($original) + 5, // length of file + version + crc