2017-08-11 11:10:27 -04:00
|
|
|
<?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
|
2017-08-14 10:56:14 -04:00
|
|
|
*/
|
|
|
|
|
class GzipFile extends TarFile
|
2017-08-11 11:10:27 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function is the constructor of the class gzip_file
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2017-08-14 10:56:14 -04:00
|
|
|
public function gzip_file($name)
|
2017-08-11 11:10:27 -04:00
|
|
|
{
|
2017-08-14 10:56:14 -04:00
|
|
|
$this->tar_file($name);
|
2017-08-11 11:10:27 -04:00
|
|
|
$this->options['type'] = "gzip";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function is employed to create files .
|
|
|
|
|
* gzip
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2017-08-14 10:56:14 -04:00
|
|
|
public function create_gzip()
|
2017-08-11 11:10:27 -04:00
|
|
|
{
|
|
|
|
|
if ($this->options['inmemory'] == 0) {
|
|
|
|
|
$pwd = getcwd();
|
2017-08-14 10:56:14 -04:00
|
|
|
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);
|
2017-08-11 11:10:27 -04:00
|
|
|
}
|
2017-08-14 10:56:14 -04:00
|
|
|
gzclose($fp);
|
|
|
|
|
chdir($pwd);
|
2017-08-11 11:10:27 -04:00
|
|
|
} else {
|
|
|
|
|
$this->error[] = "Could not open {$this->options['name']} for writing.";
|
2017-08-14 10:56:14 -04:00
|
|
|
chdir($pwd);
|
2017-08-11 11:10:27 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2017-08-14 10:56:14 -04:00
|
|
|
$this->archive = gzencode($this->archive, $this->options['level']);
|
2017-08-11 11:10:27 -04:00
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function open a archive of the class gzip_file
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2017-08-14 10:56:14 -04:00
|
|
|
public function open_archive()
|
2017-08-11 11:10:27 -04:00
|
|
|
{
|
2017-08-14 10:56:14 -04:00
|
|
|
return @gzopen($this->options['name'], "rb");
|
2017-08-11 11:10:27 -04:00
|
|
|
}
|
|
|
|
|
}
|