Skip to content

Instantly share code, notes, and snippets.

@donquixote
Last active March 29, 2016 21:26
Show Gist options
  • Save donquixote/0140b0c009370f6323c023a7e6dc3e6a to your computer and use it in GitHub Desktop.
Save donquixote/0140b0c009370f6323c023a7e6dc3e6a to your computer and use it in GitHub Desktop.
<?php
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
[..]
if ($options['nomask'] === NULL
&& $options['recurse']
// Detect patterns like '/\.tpl\.php$/' or '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\.module$/'.
// The first part is
&& preg_match('@/(.*?[^\\\\]|)((?:[_a-zA-Z0-9]|\\\\\\.)*)\$/@', $mask, $m)
) {
// Use a faster algorithm for this special case.
list(, $basename_pattern, $extension_pattern) = $m;
$basename_pattern = ('' !== $basename_pattern)
? '/' . $basename_pattern . '$/'
: NULL;
$extension = str_replace('\\.' , '.', $extension_pattern);
return _drupal_file_scan_directory_fast($dir, $basename_pattern, $extension, $options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment