+2005-11-10 Dick Porter <dick@ximian.com>
+
+ * DirectoryInfo.cs: Fix endless recursion problem with root
+ directory on windows too. Fixes bug 76191.
+
2005-11-06 Zoltan Varga <vargaz@freemail.hu>
* Directory.cs: Add stub for net 2.0 GetFiles method.
FullPath = Path.GetFullPath (path);
// Path.GetFullPath ends with / when it's the root directory (fix endless recursion problem)
- if ((path.Length > 1) || ((path [0] != Path.DirectorySeparatorChar) && (path [0] != Path.AltDirectorySeparatorChar))) {
+ if (Path.GetPathRoot (path) != path) {
char end = path [path.Length - 1];
if ((end == Path.DirectorySeparatorChar) || (end == Path.AltDirectorySeparatorChar))
FullPath += Path.DirectorySeparatorChar;
} catch (Exception e) {
AssertEquals ("GetDirectoryName Exc. #03", typeof (ArgumentException), e.GetType ());
}
+
+ if (Windows) {
+ AssertEquals ("GetDirectoryName #04", null, Path.GetDirectoryName ("C:"));
+ AssertEquals ("GetDirectoryName #05", null, Path.GetDirectoryName (@"C:\"));
+ AssertEquals ("GetDirectoryName #06", @"C:\", Path.GetDirectoryName (@"C:\dir"));
+ AssertEquals ("GetDirectoryName #07", @"C:\dir", Path.GetDirectoryName (@"C:\dir\"));
+ AssertEquals ("GetDirectoryName #08", @"C:\dir", Path.GetDirectoryName (@"C:\dir\dir"));
+ AssertEquals ("GetDirectoryName #09", @"C:\dir\dir", Path.GetDirectoryName (@"C:\dir\dir\"));
+ }
+
}
public void TestGetExtension ()
AssertEquals ("GetPathRoot w#12", String.Empty, Path.GetPathRoot ("abc//def"));
AssertEquals ("GetPathRoot w#13", "\\", Path.GetPathRoot ("/abc/def"));
AssertEquals ("GetPathRoot w#14", "\\\\abc\\def", Path.GetPathRoot ("//abc/def"));
+ AssertEquals ("GetPathRoot w#15", @"C:\", Path.GetPathRoot (@"C:\"));
+ AssertEquals ("GetPathRoot w#16", @"C:\", Path.GetPathRoot (@"C:\\"));
} else {
// TODO: Same tests for Unix.
}