Merge pull request #3274 from Unity-Technologies/fix-path-getfullpath-windows
[mono.git] / mcs / class / corlib / System.IO / Path.cs
index 9ac0e97545427ada48cdaaadfddd1f60b0eef086..d0512f24695a2a5dbe3111080092742268f8da45 100644 (file)
@@ -289,6 +289,11 @@ namespace System.IO {
                        return fullpath;
                }
 
+               internal static String GetFullPathInternal(String path)
+               {
+                       return InsecureGetFullPath (path);
+               }
+
 #if !MOBILE
                // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963%28v=vs.85%29.aspx
                [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
@@ -315,9 +320,12 @@ namespace System.IO {
 
                internal static string WindowsDriveAdjustment (string path)
                {
-                       // two special cases to consider when a drive is specified
-                       if (path.Length < 2)
+                       // three special cases to consider when a drive is specified
+                       if (path.Length < 2) {
+                               if (path.Length == 1 && (path[0] == '\\' || path[0] == '/'))
+                                       return Path.GetPathRoot(Directory.GetCurrentDirectory());
                                return path;
+                       }
                        if ((path [1] != ':') || !Char.IsLetter (path [0]))
                                return path;
 
@@ -488,7 +496,7 @@ namespace System.IO {
                                        f = new FileStream (path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.Read,
                                                            8192, false, (FileOptions) 1);
                                } catch (IOException ex){
-                                       if (ex.hresult != MonoIO.FileAlreadyExistsHResult || count ++ > 65536)
+                                       if (ex._HResult != MonoIO.FileAlreadyExistsHResult || count ++ > 65536)
                                                throw;
                                } catch (UnauthorizedAccessException ex) {
                                        if (count ++ > 65536)
@@ -871,5 +879,11 @@ namespace System.IO {
                                        throw new ArgumentException (parameterName);
                        }
                }
+
+               internal static string DirectorySeparatorCharAsString {
+                       get {
+                               return DirectorySeparatorStr;
+                       }
+               }
        }
 }