From 500f42c6bcd245bcd4e286ae5f78961022138c2a Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Thu, 29 Sep 2022 09:08:44 +0800 Subject: [PATCH] Fix hidden file glob on systems without GLOB_BRACE support --- src/Filesystem/Zip.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Filesystem/Zip.php b/src/Filesystem/Zip.php index d8ca7a62c..835a5e44f 100644 --- a/src/Filesystem/Zip.php +++ b/src/Filesystem/Zip.php @@ -152,7 +152,19 @@ public function add(string $source, array $options = []): self $folders = []; $recursive = false; } else { - $files = glob($source, GLOB_BRACE); + // Workaround for systems that do not support GLOB_BRACE (ie. Solaris, Alpine Linux) + if (!defined('GLOB_BRACE') && $includeHidden) { + $files = array_merge( + glob(dirname($source) . '/*'), + glob(dirname($source) . '/.[!.]*'), + glob(dirname($source) . '/..?*') + ); + } elseif (defined('GLOB_BRACE')) { + $files = glob($source, GLOB_BRACE); + } else { + $files = glob($source); + } + $folders = glob(dirname($source) . '/*', GLOB_ONLYDIR); }