From: Tim Düsterhus Date: Sat, 16 Jul 2011 15:10:34 +0000 (+0200) Subject: Possible negative match X-Git-Tag: 2.0.0_Beta_1~2012^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=85f63c8c29e084b202614ac0e8a86d8d3cc647d8;p=GitHub%2FWoltLab%2FWCF.git Possible negative match --- diff --git a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php index 3614e7462c..6e01af6d5e 100644 --- a/wcfsetup/install/files/lib/util/DirectoryUtil.class.php +++ b/wcfsetup/install/files/lib/util/DirectoryUtil.class.php @@ -136,10 +136,12 @@ class DirectoryUtil { /** * Returns a sorted list of files * - * @param integer $order sort-order + * @param integer $order sort-order + * @param string $pattern pattern to match + * @param boolean $negativeMatch should the pattern be inversed * @return array */ - public function getFiles($order = SORT_ASC, $pattern = '') { + public function getFiles($order = SORT_ASC, $pattern = '', $negativeMatch = false) { // scan the folder $this->scanFiles(); $files = $this->files; @@ -147,7 +149,7 @@ class DirectoryUtil { // sort out non matching files if (!empty($pattern)) { foreach ($files as $filename => $value) { - if (!preg_match($pattern, $filename)) unset($files[$filename]); + if (!preg_match($pattern, $filename) == $negativeMatch) unset($files[$filename]); } } @@ -170,10 +172,12 @@ class DirectoryUtil { /** * Returns a sorted list of files, with DirectoryIterator object as value * - * @param integer $order sort-order + * @param integer $order sort-order + * @param string $pattern pattern to match + * @param boolean $negativeMatch should the pattern be inversed * @return array */ - public function getFilesObj($order = SORT_ASC, $pattern = '') { + public function getFilesObj($order = SORT_ASC, $pattern = '', $negativeMatch = false) { // scan the folder $this->scanFilesObj(); $objects = $this->filesObj; @@ -181,7 +185,7 @@ class DirectoryUtil { // sort out non matching files if (!empty($pattern)) { foreach ($objects as $filename => $value) { - if (!preg_match($pattern, $filename)) unset($objects[$filename]); + if (!preg_match($pattern, $filename) == $negativeMatch) unset($objects[$filename]); } }