Merge branch 'fix-rare-pclzip-temp-file-issue' of github.com:andrew-kzoo/PHPWord into develop

This commit is contained in:
Ivan Lanin 2014-06-07 17:36:37 +07:00
commit bc6b40dde5
1 changed files with 7 additions and 0 deletions

View File

@ -227,7 +227,9 @@ class ZipArchive
// To Rename the file while adding it to the zip we
// need to create a temp file with the correct name
$temp_file = false;
if ($filenameParts['basename'] != $localnameParts['basename']) {
$temp_file = true; // temp file created
$temppath = $this->tempDir . '/' . $localnameParts['basename'];
copy($filename, $temppath);
$filename = $temppath;
@ -239,6 +241,11 @@ class ZipArchive
$res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded);
if($temp_file) {
// Remove temp file, if created
@unlink($this->tempDir . '/' . $localnameParts["basename"]);
}
return ($res == 0) ? false : true;
}