Spaces:
Sleeping
Sleeping
File size: 2,070 Bytes
07c3cdd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php
/*--------------------------------------------------
* TAR/GZIP/BZIP2/ZIP ARCHIVE CLASSES 2.1
* By Devin Doucette
* Copyright (c) 2005 Devin Doucette
* Email: darksnoopy@shaw.ca
*--------------------------------------------------
* Email bugs/suggestions to darksnoopy@shaw.ca
*--------------------------------------------------
* This script has been created and released under
* the GNU GPL and is free to use and redistribute
* only if this copyright statement is not removed
*--------------------------------------------------*/
/**
* This class is derived of the class archive, is employed to use archives .
* gzip
* @package workflow.engine.classes
*/
class GzipFile extends TarFile
{
/**
* This function is the constructor of the class gzip_file
*
* @param string $name
* @return void
*/
public function gzip_file($name)
{
$this->tar_file($name);
$this->options['type'] = "gzip";
}
/**
* This function is employed to create files .
* gzip
*
* @return boolean
*/
public function create_gzip()
{
if ($this->options['inmemory'] == 0) {
$pwd = getcwd();
chdir($this->options['basedir']);
if ($fp = gzopen($this->options['name'], "wb{$this->options['level']}")) {
fseek($this->archive, 0);
while ($temp = fread($this->archive, 1048576)) {
gzwrite($fp, $temp);
}
gzclose($fp);
chdir($pwd);
} else {
$this->error[] = "Could not open {$this->options['name']} for writing.";
chdir($pwd);
return 0;
}
} else {
$this->archive = gzencode($this->archive, $this->options['level']);
}
return 1;
}
/**
* This function open a archive of the class gzip_file
*
* @return void
*/
public function open_archive()
{
return @gzopen($this->options['name'], "rb");
}
}
|