internal static string InsecureGetFullPath (string path)
{
if (path == null)
throw new ArgumentNullException ("path");
if (path.Trim ().Length == 0) {
string msg = Locale.GetText ("The specified path is not of a legal form (empty).");
throw new ArgumentException (msg);
}
// adjust for drives, i.e. a special case for windows
if (Environment.IsRunningOnWindows)
path = WindowsDriveAdjustment (path);
// if the supplied path ends with a separator...
char end = path [path.Length - 1];
if (path.Length >= 2 &&
IsDsc (path [0]) &&
IsDsc (path [1])) {
if (path.Length == 2 || path.IndexOf (path [0], 2) < 0)
throw new ArgumentException ("UNC paths should be of the form \\\\server\\share.");
if (path [0] != DirectorySeparatorChar)
path = path.Replace (AltDirectorySeparatorChar, DirectorySeparatorChar);
path = CanonicalizePath (path);
} else {
if (!IsPathRooted (path))
path = Directory.GetCurrentDirectory () + DirectorySeparatorStr + path;
else if (DirectorySeparatorChar == '\\' &&
path.Length >= 2 &&
IsDsc (path [0]) &&
!IsDsc (path [1])) { // like `\abc\def'
string current = Directory.GetCurrentDirectory ();
if (current [1] == VolumeSeparatorChar)
path = current.Substring (0, 2) + path;
else
path = current.Substring (0, current.IndexOf ('\\', current.IndexOf ("\\\\") + 1));
}
path = CanonicalizePath (path);
}
// if the original ended with a [Alt]DirectorySeparatorChar then ensure the full path also ends with one
if (IsDsc (end) && (path [path.Length - 1] != DirectorySeparatorChar))
path += DirectorySeparatorChar;
return path;
}