summaryrefslogtreecommitdiff
path: root/maintenance/importImages.inc
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/importImages.inc')
-rw-r--r--maintenance/importImages.inc8
1 files changed, 6 insertions, 2 deletions
diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc
index ac5d1443..2b3d5514 100644
--- a/maintenance/importImages.inc
+++ b/maintenance/importImages.inc
@@ -28,9 +28,10 @@
*
* @param $dir string Path to directory to search
* @param $exts Array of extensions to search for
+ * @param $recurse Bool Search subdirectories recursively
* @return mixed Array of filenames on success, or false on failure
*/
-function findFiles( $dir, $exts ) {
+function findFiles( $dir, $exts, $recurse = false ) {
if ( is_dir( $dir ) ) {
$dhl = opendir( $dir );
if ( $dhl ) {
@@ -38,8 +39,11 @@ function findFiles( $dir, $exts ) {
while ( ( $file = readdir( $dhl ) ) !== false ) {
if ( is_file( $dir . '/' . $file ) ) {
list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file );
- if ( array_search( strtolower( $ext ), $exts ) !== false )
+ if ( array_search( strtolower( $ext ), $exts ) !== false ) {
$files[] = $dir . '/' . $file;
+ }
+ } elseif ( $recurse && is_dir( $dir . '/' . $file ) && $file !== '..' && $file !== '.' ) {
+ $files = array_merge( $files, findFiles( $dir . '/' . $file, $exts, true ) );
}
}
return $files;