function _drupal_get_filename_perform_file_scan
_drupal_get_filename_perform_file_scan($type, $name)
Performs a file system scan to search for a system resource.
Parameters
$type: The type of the item (theme, theme_engine, module, profile).
$name: The name of the item for which the filename is requested.
Return value
The filename of the requested item or FALSE if the item is not found.
See also
_drupal_get_filename_fallback()
File
- includes/bootstrap.inc, line 1018
- Functions that need to be loaded on every Drupal request.
Code
function _drupal_get_filename_perform_file_scan($type, $name) { // The location of files will not change during the request, so do not use // drupal_static(). static $dirs = array(), $files = array(); // We have a consistent directory naming: modules, themes... $dir = $type . 's'; if ($type == 'theme_engine') { $dir = 'themes/engines'; $extension = 'engine'; } elseif ($type == 'theme') { $extension = 'info'; } else { $extension = $type; } // Check if we had already scanned this directory/extension combination. if (!isset($dirs[$dir][$extension])) { // Log that we have now scanned this directory/extension combination // into a static variable so as to prevent unnecessary file scans. $dirs[$dir][$extension] = TRUE; if (!function_exists('drupal_system_listing')) { require_once DRUPAL_ROOT . '/includes/common.inc'; } // Scan the appropriate directories for all files with the requested // extension, not just the file we are currently looking for. This // prevents unnecessary scans from being repeated when this function is // called more than once in the same page request. $matches = drupal_system_listing("/^" . DRUPAL_PHP_FUNCTION_PATTERN . "\.$extension$/", $dir, 'name', 0); foreach ($matches as $matched_name => $file) { // Log the locations found in the file scan into a static variable. $files[$type][$matched_name] = $file->uri; } } // Return the results of the file system scan, or FALSE to indicate the file // was not found. return isset($files[$type][$name]) ? $files[$type][$name] : FALSE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/_drupal_get_filename_perform_file_scan/7.x