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

GetSchemeInternal() static private method

Checks if the given path is a filesystem path or an URL and returns the corresponding scheme.
static private GetSchemeInternal ( string path, string &filename ) : string
path string The path to be canonicalized.
filename string The filesystem path before canonicalization (may be both relative or absolute).
return string
        internal static string GetSchemeInternal(string path, out string filename)
        {
            int colon_index = path.IndexOf(':');
            if (colon_index == -1)
            {
                // No scheme, no root directory, it's a relative path.
                filename = path;
                return "file";
            }

            if (Path.IsPathRooted(path))
            {
                // It already is an absolute path.
                filename = path;
                return "file";
            }

            if (path.Length < colon_index + 3 || path[colon_index + 1] != '/' || path[colon_index + 2] != '/')
            {
                // There is no "//" following the colon.
                filename = path;
                return "file";
            }

            // Otherwise it is an URL (including file://), set the filename and return the scheme.
            filename = path.Substring(colon_index + "://".Length);
            return path.Substring(0, colon_index);
        }