wp-optimize
/
vendor
/
robloach
/
component-installer
/
src
/
ComponentInstaller
/
Util
/
Filesystem.php
Filesystem.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/robloach/component-installer/src/ComponentInstaller/Util/Filesystem.php
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of Component Installer. |
| 5 | * |
| 6 | * (c) Rob Loach (http://robloach.net) |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE.md |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | |
| 12 | namespace ComponentInstaller\Util; |
| 13 | |
| 14 | use Composer\Util\Filesystem as BaseFilesystem; |
| 15 | |
| 16 | /** |
| 17 | * Provides basic file system operations. |
| 18 | */ |
| 19 | class Filesystem extends BaseFilesystem |
| 20 | { |
| 21 | /** |
| 22 | * Performs a recursive-enabled glob search with the given pattern. |
| 23 | * |
| 24 | * @param string $pattern |
| 25 | * The pattern passed to glob(). If the pattern contains "**", then it |
| 26 | * a recursive search will be used. |
| 27 | * @param int $flags |
| 28 | * Flags to pass into glob(). |
| 29 | * |
| 30 | * @return mixed |
| 31 | * An array of files that match the recursive pattern given. |
| 32 | */ |
| 33 | public function recursiveGlob($pattern, $flags = 0) |
| 34 | { |
| 35 | // Perform the glob search. |
| 36 | $files = glob($pattern, $flags); |
| 37 | |
| 38 | // Check if this is to be recursive. |
| 39 | if (strpos($pattern, '**') !== FALSE) { |
| 40 | foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
| 41 | $files = array_merge($files, $this->recursiveGlob($dir.'/'.basename($pattern), $flags)); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return $files; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Performs a recursive glob search for files with the given pattern. |
| 50 | * |
| 51 | * @param string $pattern |
| 52 | * The pattern passed to glob(). |
| 53 | * @param int $flags |
| 54 | * Flags to pass into glob(). |
| 55 | * |
| 56 | * @return mixed |
| 57 | * An array of files that match the recursive pattern given. |
| 58 | */ |
| 59 | public function recursiveGlobFiles($pattern, $flags = 0) |
| 60 | { |
| 61 | $files = $this->recursiveGlob($pattern, $flags); |
| 62 | |
| 63 | return array_filter($files, 'is_file'); |
| 64 | } |
| 65 | } |
| 66 |