Commit 9d5e8026 authored by alexpott's avatar alexpott
Browse files

Issue #1165694 by pillarsdotnet, Sutharsan, droplet: Remove default nomask...

Issue #1165694 by pillarsdotnet, Sutharsan, droplet: Remove default nomask from file_scan_directory().
parent 3d5f960b
...@@ -1145,18 +1145,18 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX ...@@ -1145,18 +1145,18 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
/** /**
* Finds all files that match a given mask in a given directory. * Finds all files that match a given mask in a given directory.
* *
* Directories and files beginning with a period are excluded; this * Directories and files beginning with a dot are excluded; this prevents
* prevents hidden files and directories (such as SVN working directories) * hidden files and directories (such as SVN working directories) from being
* from being scanned. * scanned.
* *
* @param $dir * @param $dir
* The base directory or URI to scan, without trailing slash. * The base directory or URI to scan, without trailing slash.
* @param $mask * @param $mask
* The preg_match() regular expression of the files to find. * The preg_match() regular expression for files to be included.
* @param $options * @param $options
* An associative array of additional options, with the following elements: * An associative array of additional options, with the following elements:
* - 'nomask': The preg_match() regular expression of the files to ignore. * - 'nomask': The preg_match() regular expression for files to be excluded.
* Defaults to '/(\.\.?|CVS)$/'. * There is no default.
* - 'callback': The callback function to call for each match. There is no * - 'callback': The callback function to call for each match. There is no
* default callback. * default callback.
* - 'recurse': When TRUE, the directory scan will recurse the entire tree * - 'recurse': When TRUE, the directory scan will recurse the entire tree
...@@ -1168,17 +1168,16 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX ...@@ -1168,17 +1168,16 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
* - 'min_depth': Minimum depth of directories to return files from. Defaults * - 'min_depth': Minimum depth of directories to return files from. Defaults
* to 0. * to 0.
* @param $depth * @param $depth
* Current depth of recursion. This parameter is only used internally and * The current depth of recursion. This parameter is only used internally and
* should not be passed in. * should not be passed in.
* *
* @return * @return
* An associative array (keyed on the chosen key) of objects with 'uri', * An associative array (keyed on the chosen key) of objects with 'uri',
* 'filename', and 'name' members corresponding to the matching files. * 'filename', and 'name' properties corresponding to the matched files.
*/ */
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
// Merge in defaults. // Merge in defaults.
$options += array( $options += array(
'nomask' => '/^CVS$/',
'callback' => 0, 'callback' => 0,
'recurse' => TRUE, 'recurse' => TRUE,
'key' => 'uri', 'key' => 'uri',
...@@ -1198,7 +1197,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { ...@@ -1198,7 +1197,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
if ($handle = @opendir($dir)) { if ($handle = @opendir($dir)) {
while (FALSE !== ($filename = readdir($handle))) { while (FALSE !== ($filename = readdir($handle))) {
// Skip this file if it matches the nomask or starts with a dot. // Skip this file if it matches the nomask or starts with a dot.
if ($filename[0] != '.' && !preg_match($options['nomask'], $filename)) { if ($filename[0] != '.' && !(isset($options['nomask']) && preg_match($options['nomask'], $filename))) {
if ($depth == 0 && $dir_has_slash) { if ($depth == 0 && $dir_has_slash) {
$uri = "$dir$filename"; $uri = "$dir$filename";
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment