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);
}