Reorder code

This commit is contained in:
Ivan Lanin 2014-05-18 02:21:26 +07:00
parent 0a8c3d6cc2
commit f825ef50c0
1 changed files with 25 additions and 26 deletions

View File

@ -89,8 +89,6 @@ class ZipArchive
define('PCLZIP_TEMPORARY_DIR', sys_get_temp_dir() . '/');
}
require_once 'PCLZip/pclzip.lib.php';
} else {
$this->zip = new \ZipArchive();
}
}
@ -120,6 +118,31 @@ class ZipArchive
return $result;
}
/**
* Open a new zip archive
*
* @param string $filename The file name of the ZIP archive to open
* @param int $flags The mode to use to open the archive
* @return bool
*/
public function open($filename, $flags = null)
{
$result = true;
$this->filename = $filename;
if (!$this->usePclzip) {
$this->zip = new \ZipArchive();
$result = $this->zip->open($this->filename, $flags);
$this->numFiles = $this->zip->numFiles;
} else {
$this->zip = new \PclZip($this->filename);
$this->tempDir = sys_get_temp_dir();
$this->numFiles = count($this->zip->listContent());
}
return $result;
}
/**
* Close the active archive
*
@ -158,30 +181,6 @@ class ZipArchive
}
}
/**
* Open a new zip archive
*
* @param string $filename The file name of the ZIP archive to open
* @param int $flags The mode to use to open the archive
* @return bool
*/
public function open($filename, $flags = null)
{
$result = true;
$this->filename = $filename;
if (!$this->usePclzip) {
$result = $this->zip->open($this->filename, $flags);
$this->numFiles = $this->zip->numFiles;
} else {
$this->tempDir = sys_get_temp_dir();
$this->zip = new \PclZip($this->filename);
$this->numFiles = count($this->zip->listContent());
}
return $result;
}
/**
* Extract file from archive by given file name (emulate \ZipArchive)
*