mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Internal zipping broken on win32 MDL-7105 ; we are now using the new method to specify file names in zip archive because the old PCLZIP_OPT_REMOVE_PATH option is broken on win32 platforms
This commit is contained in:
parent
b2ad03364b
commit
6a1cfff27e
1 changed files with 11 additions and 1 deletions
|
@ -6114,8 +6114,18 @@ function zip_files ($originalfiles, $destination) {
|
||||||
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
||||||
|
|
||||||
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
|
include_once("$CFG->libdir/pclzip/pclzip.lib.php");
|
||||||
|
//rewrite filenames because the old method with PCLZIP_OPT_REMOVE_PATH does not work under win32
|
||||||
|
$zipfiles = array();
|
||||||
|
$start = strlen($origpath)+1;
|
||||||
|
foreach($files as $file) {
|
||||||
|
$tf = array();
|
||||||
|
$tf[PCLZIP_ATT_FILE_NAME] = $file;
|
||||||
|
$tf[PCLZIP_ATT_FILE_NEW_FULL_NAME] = substr($file, $start);
|
||||||
|
$zipfiles[] = $tf;
|
||||||
|
}
|
||||||
|
//create the archive
|
||||||
$archive = new PclZip(cleardoubleslashes("$destpath/$destfilename"));
|
$archive = new PclZip(cleardoubleslashes("$destpath/$destfilename"));
|
||||||
if (($list = $archive->create($files, PCLZIP_OPT_REMOVE_PATH,$origpath) == 0)) {
|
if (($list = $archive->create($zipfiles) == 0)) {
|
||||||
notice($archive->errorInfo(true));
|
notice($archive->errorInfo(true));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue