|
@@ -2004,11 +2004,15 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring
|
|
|
// Skip directories (they would be added automatically)
|
|
|
if (!$file->isDir()) {
|
|
|
// Get real and relative path for current file
|
|
|
- $filePath = $file->getRealPath();
|
|
|
- $relativePath = substr($filePath, strlen($rootPath) + 1);
|
|
|
+ $filePath = $file->getPath(); // the full path with filename using the $inputdir root.
|
|
|
+ $fileName = $file->getFilename();
|
|
|
+ $fileFullRealPath = $file->getRealPath(); // the full path with name and transformed to use real path directory.
|
|
|
+
|
|
|
+ //$relativePath = substr($fileFullRealPath, strlen($rootPath) + 1);
|
|
|
+ $relativePath = substr(($filePath ? $filePath.'/' : '').$fileName, strlen($rootPath) + 1);
|
|
|
|
|
|
// Add current file to archive
|
|
|
- $zip->addFile($filePath, $relativePath);
|
|
|
+ $zip->addFile($fileFullRealPath, $relativePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2196,22 +2200,29 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles =
|
|
|
}
|
|
|
|
|
|
// Create recursive directory iterator
|
|
|
+ // This does not return symbolic links
|
|
|
/** @var SplFileInfo[] $files */
|
|
|
$files = new RecursiveIteratorIterator(
|
|
|
new RecursiveDirectoryIterator($inputdir),
|
|
|
RecursiveIteratorIterator::LEAVES_ONLY
|
|
|
);
|
|
|
|
|
|
+ //var_dump($inputdir);
|
|
|
foreach ($files as $name => $file) {
|
|
|
// Skip directories (they would be added automatically)
|
|
|
if (!$file->isDir()) {
|
|
|
// Get real and relative path for current file
|
|
|
- $filePath = $file->getRealPath();
|
|
|
- $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1);
|
|
|
+ $filePath = $file->getPath(); // the full path with filename using the $inputdir root.
|
|
|
+ $fileName = $file->getFilename();
|
|
|
+ $fileFullRealPath = $file->getRealPath(); // the full path with name and transformed to use real path directory.
|
|
|
+
|
|
|
+ //$relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($fileFullRealPath, strlen($inputdir) + 1);
|
|
|
+ $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr(($filePath ? $filePath.'/' : '').$fileName, strlen($inputdir) + 1);
|
|
|
|
|
|
- if (empty($excludefiles) || !preg_match($excludefiles, $filePath)) {
|
|
|
+ //var_dump($filePath);var_dump($fileFullRealPath);var_dump($relativePath);
|
|
|
+ if (empty($excludefiles) || !preg_match($excludefiles, $fileFullRealPath)) {
|
|
|
// Add current file to archive
|
|
|
- $zip->addFile($filePath, $relativePath);
|
|
|
+ $zip->addFile($fileFullRealPath, $relativePath);
|
|
|
}
|
|
|
}
|
|
|
}
|