mirror of
https://github.com/splitbrain/dokuwiki-plugin-upgrade.git
synced 2025-08-11 23:31:56 +00:00
fixed references to constants in tar lib. closes #40
This commit is contained in:
@ -17,7 +17,7 @@ class VerboseTar {
|
|||||||
const COMPRESS_BZIP = 3;
|
const COMPRESS_BZIP = 3;
|
||||||
|
|
||||||
protected $file = '';
|
protected $file = '';
|
||||||
protected $comptype = Tar::COMPRESS_AUTO;
|
protected $comptype = self::COMPRESS_AUTO;
|
||||||
protected $fh;
|
protected $fh;
|
||||||
protected $memory = '';
|
protected $memory = '';
|
||||||
protected $closed = true;
|
protected $closed = true;
|
||||||
@ -30,17 +30,17 @@ class VerboseTar {
|
|||||||
* @param int $comptype
|
* @param int $comptype
|
||||||
* @throws VerboseTarIOException
|
* @throws VerboseTarIOException
|
||||||
*/
|
*/
|
||||||
public function open($file, $comptype = Tar::COMPRESS_AUTO) {
|
public function open($file, $comptype = self::COMPRESS_AUTO) {
|
||||||
// determine compression
|
// determine compression
|
||||||
if($comptype == Tar::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
if($comptype == self::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
||||||
$this->compressioncheck($comptype);
|
$this->compressioncheck($comptype);
|
||||||
|
|
||||||
$this->comptype = $comptype;
|
$this->comptype = $comptype;
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
|
||||||
if($this->comptype === Tar::COMPRESS_GZIP) {
|
if($this->comptype === self::COMPRESS_GZIP) {
|
||||||
$this->fh = @gzopen($this->file, 'rb');
|
$this->fh = @gzopen($this->file, 'rb');
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
$this->fh = @bzopen($this->file, 'r');
|
$this->fh = @bzopen($this->file, 'r');
|
||||||
} else {
|
} else {
|
||||||
$this->fh = @fopen($this->file, 'rb');
|
$this->fh = @fopen($this->file, 'rb');
|
||||||
@ -209,9 +209,9 @@ class VerboseTar {
|
|||||||
* @throws VerboseTarIOException
|
* @throws VerboseTarIOException
|
||||||
* @throws VerboseTarIllegalCompressionException
|
* @throws VerboseTarIllegalCompressionException
|
||||||
*/
|
*/
|
||||||
public function create($file = '', $comptype = Tar::COMPRESS_AUTO, $complevel = 9) {
|
public function create($file = '', $comptype = self::COMPRESS_AUTO, $complevel = 9) {
|
||||||
// determine compression
|
// determine compression
|
||||||
if($comptype == Tar::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
if($comptype == self::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
||||||
$this->compressioncheck($comptype);
|
$this->compressioncheck($comptype);
|
||||||
|
|
||||||
$this->comptype = $comptype;
|
$this->comptype = $comptype;
|
||||||
@ -220,9 +220,9 @@ class VerboseTar {
|
|||||||
$this->fh = 0;
|
$this->fh = 0;
|
||||||
|
|
||||||
if($this->file) {
|
if($this->file) {
|
||||||
if($this->comptype === Tar::COMPRESS_GZIP) {
|
if($this->comptype === self::COMPRESS_GZIP) {
|
||||||
$this->fh = @gzopen($this->file, 'wb'.$complevel);
|
$this->fh = @gzopen($this->file, 'wb'.$complevel);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
$this->fh = @bzopen($this->file, 'w');
|
$this->fh = @bzopen($this->file, 'w');
|
||||||
} else {
|
} else {
|
||||||
$this->fh = @fopen($this->file, 'wb');
|
$this->fh = @fopen($this->file, 'wb');
|
||||||
@ -326,9 +326,9 @@ class VerboseTar {
|
|||||||
|
|
||||||
// close file handles
|
// close file handles
|
||||||
if($this->file) {
|
if($this->file) {
|
||||||
if($this->comptype === Tar::COMPRESS_GZIP) {
|
if($this->comptype === self::COMPRESS_GZIP) {
|
||||||
gzclose($this->fh);
|
gzclose($this->fh);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
bzclose($this->fh);
|
bzclose($this->fh);
|
||||||
} else {
|
} else {
|
||||||
fclose($this->fh);
|
fclose($this->fh);
|
||||||
@ -346,14 +346,14 @@ class VerboseTar {
|
|||||||
*
|
*
|
||||||
* This implicitly calls close() on the Archive
|
* This implicitly calls close() on the Archive
|
||||||
*/
|
*/
|
||||||
public function getArchive($comptype = Tar::COMPRESS_AUTO, $complevel = 9) {
|
public function getArchive($comptype = self::COMPRESS_AUTO, $complevel = 9) {
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
||||||
if($comptype === Tar::COMPRESS_AUTO) $comptype = $this->comptype;
|
if($comptype === self::COMPRESS_AUTO) $comptype = $this->comptype;
|
||||||
$this->compressioncheck($comptype);
|
$this->compressioncheck($comptype);
|
||||||
|
|
||||||
if($comptype === Tar::COMPRESS_GZIP) return gzcompress($this->memory, $complevel);
|
if($comptype === self::COMPRESS_GZIP) return gzcompress($this->memory, $complevel);
|
||||||
if($comptype === Tar::COMPRESS_BZIP) return bzcompress($this->memory);
|
if($comptype === self::COMPRESS_BZIP) return bzcompress($this->memory);
|
||||||
return $this->memory;
|
return $this->memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +368,8 @@ class VerboseTar {
|
|||||||
* @param int $complevel
|
* @param int $complevel
|
||||||
* @throws VerboseTarIOException
|
* @throws VerboseTarIOException
|
||||||
*/
|
*/
|
||||||
public function save($file, $comptype = Tar::COMPRESS_AUTO, $complevel = 9) {
|
public function save($file, $comptype = self::COMPRESS_AUTO, $complevel = 9) {
|
||||||
if($comptype === Tar::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
if($comptype === self::COMPRESS_AUTO) $comptype = $this->filetype($file);
|
||||||
|
|
||||||
if(!file_put_contents($file, $this->getArchive($comptype, $complevel))) {
|
if(!file_put_contents($file, $this->getArchive($comptype, $complevel))) {
|
||||||
throw new VerboseTarIOException('Could not write to file: '.$file);
|
throw new VerboseTarIOException('Could not write to file: '.$file);
|
||||||
@ -383,9 +383,9 @@ class VerboseTar {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function readbytes($length) {
|
protected function readbytes($length) {
|
||||||
if($this->comptype === Tar::COMPRESS_GZIP) {
|
if($this->comptype === self::COMPRESS_GZIP) {
|
||||||
return @gzread($this->fh, $length);
|
return @gzread($this->fh, $length);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
return @bzread($this->fh, $length);
|
return @bzread($this->fh, $length);
|
||||||
} else {
|
} else {
|
||||||
return @fread($this->fh, $length);
|
return @fread($this->fh, $length);
|
||||||
@ -403,9 +403,9 @@ class VerboseTar {
|
|||||||
if(!$this->file) {
|
if(!$this->file) {
|
||||||
$this->memory .= $data;
|
$this->memory .= $data;
|
||||||
$written = strlen($data);
|
$written = strlen($data);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_GZIP) {
|
} elseif($this->comptype === self::COMPRESS_GZIP) {
|
||||||
$written = @gzwrite($this->fh, $data);
|
$written = @gzwrite($this->fh, $data);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
$written = @bzwrite($this->fh, $data);
|
$written = @bzwrite($this->fh, $data);
|
||||||
} else {
|
} else {
|
||||||
$written = @fwrite($this->fh, $data);
|
$written = @fwrite($this->fh, $data);
|
||||||
@ -422,9 +422,9 @@ class VerboseTar {
|
|||||||
* @param int $bytes seek to this position
|
* @param int $bytes seek to this position
|
||||||
*/
|
*/
|
||||||
function skipbytes($bytes) {
|
function skipbytes($bytes) {
|
||||||
if($this->comptype === Tar::COMPRESS_GZIP) {
|
if($this->comptype === self::COMPRESS_GZIP) {
|
||||||
@gzseek($this->fh, $bytes, SEEK_CUR);
|
@gzseek($this->fh, $bytes, SEEK_CUR);
|
||||||
} elseif($this->comptype === Tar::COMPRESS_BZIP) {
|
} elseif($this->comptype === self::COMPRESS_BZIP) {
|
||||||
// there is no seek in bzip2, we simply read on
|
// there is no seek in bzip2, we simply read on
|
||||||
@bzread($this->fh, $bytes);
|
@bzread($this->fh, $bytes);
|
||||||
} else {
|
} else {
|
||||||
@ -562,11 +562,11 @@ class VerboseTar {
|
|||||||
* @throws VerboseTarIllegalCompressionException
|
* @throws VerboseTarIllegalCompressionException
|
||||||
*/
|
*/
|
||||||
protected function compressioncheck($comptype) {
|
protected function compressioncheck($comptype) {
|
||||||
if($comptype === Tar::COMPRESS_GZIP && !function_exists('gzopen')) {
|
if($comptype === self::COMPRESS_GZIP && !function_exists('gzopen')) {
|
||||||
throw new VerboseTarIllegalCompressionException('No gzip support available');
|
throw new VerboseTarIllegalCompressionException('No gzip support available');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($comptype === Tar::COMPRESS_BZIP && !function_exists('bzopen')) {
|
if($comptype === self::COMPRESS_BZIP && !function_exists('bzopen')) {
|
||||||
throw new VerboseTarIllegalCompressionException('No bzip2 support available');
|
throw new VerboseTarIllegalCompressionException('No bzip2 support available');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ class VerboseTar {
|
|||||||
/**
|
/**
|
||||||
* Guesses the wanted compression from the given filename extension
|
* Guesses the wanted compression from the given filename extension
|
||||||
*
|
*
|
||||||
* You don't need to call this yourself. It's used when you pass Tar::COMPRESS_AUTO somewhere
|
* You don't need to call this yourself. It's used when you pass self::COMPRESS_AUTO somewhere
|
||||||
*
|
*
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return int
|
* @return int
|
||||||
@ -582,11 +582,11 @@ class VerboseTar {
|
|||||||
public function filetype($file) {
|
public function filetype($file) {
|
||||||
$file = strtolower($file);
|
$file = strtolower($file);
|
||||||
if(substr($file, -3) == '.gz' || substr($file, -4) == '.tgz') {
|
if(substr($file, -3) == '.gz' || substr($file, -4) == '.tgz') {
|
||||||
$comptype = Tar::COMPRESS_GZIP;
|
$comptype = self::COMPRESS_GZIP;
|
||||||
} elseif(substr($file, -4) == '.bz2' || substr($file, -4) == '.tbz') {
|
} elseif(substr($file, -4) == '.bz2' || substr($file, -4) == '.tbz') {
|
||||||
$comptype = Tar::COMPRESS_BZIP;
|
$comptype = self::COMPRESS_BZIP;
|
||||||
} else {
|
} else {
|
||||||
$comptype = Tar::COMPRESS_NONE;
|
$comptype = self::COMPRESS_NONE;
|
||||||
}
|
}
|
||||||
return $comptype;
|
return $comptype;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user