Minor refactoring of "Shared\ZipArchive" class.
This commit is contained in:
parent
e31f080ea6
commit
3d06c77fc1
|
|
@ -158,7 +158,7 @@ class ZipArchive
|
|||
{
|
||||
if (!$this->usePclzip) {
|
||||
if ($this->zip->close() === false) {
|
||||
throw new Exception("Could not close zip file $this->filename.");
|
||||
throw new Exception("Could not close zip file {$this->filename}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ class ZipArchive
|
|||
$tempFile = false;
|
||||
if ($filenameParts['basename'] != $localnameParts['basename']) {
|
||||
$tempFile = true; // temp file created
|
||||
$temppath = $this->tempDir . '/' . $localnameParts['basename'];
|
||||
$temppath = $this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename'];
|
||||
copy($filename, $temppath);
|
||||
$filename = $temppath;
|
||||
$filenameParts = pathinfo($temppath);
|
||||
|
|
@ -246,7 +246,7 @@ class ZipArchive
|
|||
|
||||
if ($tempFile) {
|
||||
// Remove temp file, if created
|
||||
@unlink($this->tempDir . '/' . $localnameParts["basename"]);
|
||||
unlink($this->tempDir . DIRECTORY_SEPARATOR . $localnameParts['basename']);
|
||||
}
|
||||
|
||||
return ($res == 0) ? false : true;
|
||||
|
|
@ -266,19 +266,19 @@ class ZipArchive
|
|||
$filenameParts = pathinfo($localname);
|
||||
|
||||
// Write $contents to a temp file
|
||||
$handle = fopen($this->tempDir . '/' . $filenameParts["basename"], "wb");
|
||||
$handle = fopen($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'], 'wb');
|
||||
fwrite($handle, $contents);
|
||||
fclose($handle);
|
||||
|
||||
// Add temp file to zip
|
||||
$filename = $this->tempDir . '/' . $filenameParts["basename"];
|
||||
$filename = $this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename'];
|
||||
$pathRemoved = $this->tempDir;
|
||||
$pathAdded = $filenameParts['dirname'];
|
||||
|
||||
$res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded);
|
||||
|
||||
// Remove temp file
|
||||
@unlink($this->tempDir . '/' . $filenameParts["basename"]);
|
||||
@unlink($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']);
|
||||
|
||||
return ($res == 0) ? false : true;
|
||||
}
|
||||
|
|
@ -338,7 +338,7 @@ class ZipArchive
|
|||
$extracted = $zip->extractByIndex($listIndex, PCLZIP_OPT_EXTRACT_AS_STRING);
|
||||
}
|
||||
if ((is_array($extracted)) && ($extracted != 0)) {
|
||||
$contents = $extracted[0]["content"];
|
||||
$contents = $extracted[0]['content'];
|
||||
}
|
||||
|
||||
return $contents;
|
||||
|
|
@ -377,8 +377,8 @@ class ZipArchive
|
|||
$listCount = count($list);
|
||||
$listIndex = -1;
|
||||
for ($i = 0; $i < $listCount; ++$i) {
|
||||
if (strtolower($list[$i]["filename"]) == strtolower($filename) ||
|
||||
strtolower($list[$i]["stored_filename"]) == strtolower($filename)) {
|
||||
if (strtolower($list[$i]['filename']) == strtolower($filename) ||
|
||||
strtolower($list[$i]['stored_filename']) == strtolower($filename)) {
|
||||
$listIndex = $i;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue