private FullPath SearchForIncludedFile(PhpError errorSeverity, string includedPath, FullPath includerFullPath)
{
FullPath result;
string message;
//
// construct the delegate checking the script existance
//
var file_exists = applicationContext.BuildFileExistsDelegate();
//
// try to find the script
//
if (file_exists != null)
{
string includer_directory = includerFullPath.IsEmpty ? WorkingDirectory : Path.GetDirectoryName(includerFullPath);
// searches for file in the following order:
// - incomplete absolute path => combines with RootOf(WorkingDirectory)
// - relative path => searches in FileSystem.IncludePaths then in the includer source directory
result = PhpScript.FindInclusionTargetPath(
new InclusionResolutionContext(
applicationContext,
includer_directory,
WorkingDirectory,
config.FileSystem.IncludePaths
),
includedPath,
file_exists,
out message);
}
else
{
message = "Script cannot be included with current configuration."; // there is no precompiled MSA available on non-web application
result = FullPath.Empty;
}
// failure:
if (result.IsEmpty)
{
PhpException.Throw(errorSeverity,
CoreResources.GetString("script_inclusion_failed",
includedPath,
message,
config.FileSystem.IncludePaths,
WorkingDirectory));
}
return result;
}