Changeset 13136
- Timestamp:
- 01/22/2024 05:31:04 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-filesystem.php
r9995 r13136 87 87 */ 88 88 public static function list_files( $directory, $recursive = false, $pattern = null, $depth = -1 ) { 89 return self::list( $directory, 'files', $recursive, $pattern, $depth ); 90 } 91 92 /** 93 * Returns all (usable) files/directories of a given directory. 94 * 95 * @static 96 * 97 * @param string $directory Path to directory to search. 98 * @param bool $type Optional. Whether to return 'files', 'directories', or 'all'. Default: 'all'. 99 * @param bool $recursive Optional. Whether to recurse into subdirectories. Default: false. 100 * @param string $pattern Optional. A regular expression to match files against. Default: null. 101 * @param int $depth Optional. Recursion depth. Default: -1 (infinite). 102 * @return array All files within the passed directory. 103 */ 104 public static function list( $directory, $type = 'all', $recursive = false, $pattern = null, $depth = -1 ) { 89 105 if ( $recursive ) { 90 106 $iterator = new \RecursiveIteratorIterator( … … 105 121 $files = array(); 106 122 foreach ( $filtered as $file ) { 107 if ( ! $file->isFile() ) { 123 if ( in_array( $file->getFilename(), [ '.', '..' ] ) ) { 124 continue; 125 } elseif ( 'files' === $type && ! $file->isFile() ) { 126 continue; 127 } elseif ( 'directories' === $type && ! $file->isDir() ) { 108 128 continue; 109 129 } elseif ( stristr( $file->getPathname(), '__MACOSX' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.