Pchp.Library.Streams.PhpStream.CheckIncludePath C# (CSharp) Method

CheckIncludePath() private static method

Check if the path lays inside of the directory tree specified by the open_basedir configuration option and return the resulting absolutePath.
private static CheckIncludePath ( Context ctx, string relativePath, string &absolutePath ) : bool
ctx Pchp.Core.Context Current runtime context.
relativePath string The filename to search for.
absolutePath string The combined absolute path (either in the working directory /// or in an include path wherever it has been found first).
return bool
        private static bool CheckIncludePath(Context ctx, string relativePath, ref string absolutePath)
        {
            // Note: If the absolutePath exists, it overtakse the include_path search.
            if (Path.IsPathRooted(relativePath)) return false;
            if (File.Exists(absolutePath)) return false;

            var paths = ctx.IncludePaths;
            if (paths == null || paths.Length == 0) return false;

            foreach (string s in paths)
            {
                if (string.IsNullOrEmpty(s)) continue;
                string abs = Path.GetFullPath(Path.Combine(s, relativePath));
                if (File.Exists(abs))
                {
                    absolutePath = abs;
                    return true;
                }
            }
            return false;
        }