private function _resolveFilename(&$filename, $use_include_path = false)
{
$exists = file_exists($filename);
// The given filename did not suffice. Let's do a deeper check.
if (!$exists && $use_include_path && substr($filename, 0, 1) !== '/') {
// Gather the include paths.
$paths = explode(':', get_include_path());
// Walk through the include paths.
foreach ($paths as $path) {
// Check if the file exists within this path.
$exists = realpath($path . '/' . $filename);
// It didn't work. Move along.
if (!$exists) {
continue;
}
// It actually did work. Now overwrite my filename.
$filename = $exists;
$exists = true;
break;
}
}
return $exists && is_readable($filename);
}