From dad96cc30957e1fadafe824df9c9c0b2dcd57b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Gris?= Date: Sun, 28 Apr 2024 01:24:57 +0200 Subject: [PATCH] Fix(Task/Ext/Archive/ZipTask): Preseves directories' permissions in zip Fix #1817 When file permissions are supported, stores directories's original permissions as `ZipArchive::OPSYS_UNIX` `ExternalAttribute`. --- src/Phing/Task/Ext/Archive/ZipTask.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Phing/Task/Ext/Archive/ZipTask.php b/src/Phing/Task/Ext/Archive/ZipTask.php index c1bcddfe5..c7cd600a8 100644 --- a/src/Phing/Task/Ext/Archive/ZipTask.php +++ b/src/Phing/Task/Ext/Archive/ZipTask.php @@ -306,6 +306,12 @@ private function addFilesetsToArchive($zip) if ($f->isDirectory()) { if ($pathInZip != '.') { $zip->addEmptyDir($pathInZip); + $filePerms = fileperms($f->getPath()); + if (false !== $filePerms) { // filePerms supported + $dirAttrs = $filePerms << 16; + $dirAttrName = $pathInZip . '/'; + $zip->setExternalAttributesName($dirAttrName, \ZipArchive::OPSYS_UNIX, $dirAttrs); + } } } else { $zip->addFile($f->getAbsolutePath(), $pathInZip);