diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-03-02 20:18:51 +0300 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-03-02 20:18:51 +0300 |
commit | 875ad2454d463a616888502e38cbe04544076048 (patch) | |
tree | ddcf67f1b298e147b31e38fb2c091143a8070a4c | |
parent | d4182fdfacd7a6570eeed8161bc85bf0e5c0c268 (diff) |
2003-03-02 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* DirectoryInfo.cs: changed ToString to match MS behavior.
* Path.cs: further fixes to GetDirectoryName to return null in the
same cases that MS does.
Fixes bug #38387.
svn path=/trunk/mcs/; revision=12105
-rw-r--r-- | mcs/class/corlib/System.IO/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/corlib/System.IO/DirectoryInfo.cs | 2 | ||||
-rw-r--r-- | mcs/class/corlib/System.IO/Path.cs | 33 |
3 files changed, 23 insertions, 20 deletions
diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog index e28065bdae7..fb8dd1ebe9b 100644 --- a/mcs/class/corlib/System.IO/ChangeLog +++ b/mcs/class/corlib/System.IO/ChangeLog @@ -1,5 +1,13 @@ 2003-03-02 Gonzalo Paniagua Javier <gonzalo@ximian.com> + * DirectoryInfo.cs: changed ToString to match MS behavior. + * Path.cs: further fixes to GetDirectoryName to return null in the + same cases that MS does. + + Fixes bug #38387. + +2003-03-02 Gonzalo Paniagua Javier <gonzalo@ximian.com> + * Path.cs: fixed a couple of bugs reported in #35906. 2003-03-01 Gonzalo Paniagua Javier <gonzalo@ximian.com> diff --git a/mcs/class/corlib/System.IO/DirectoryInfo.cs b/mcs/class/corlib/System.IO/DirectoryInfo.cs index 21d0329b5a9..78719bd4607 100644 --- a/mcs/class/corlib/System.IO/DirectoryInfo.cs +++ b/mcs/class/corlib/System.IO/DirectoryInfo.cs @@ -129,7 +129,7 @@ namespace System.IO { }
public override string ToString () {
- return OriginalPath;
+ return Path.GetFileName (OriginalPath);
}
}
}
diff --git a/mcs/class/corlib/System.IO/Path.cs b/mcs/class/corlib/System.IO/Path.cs index b545be4c4d7..aec8e670c17 100644 --- a/mcs/class/corlib/System.IO/Path.cs +++ b/mcs/class/corlib/System.IO/Path.cs @@ -94,25 +94,20 @@ namespace System.IO public static string GetDirectoryName (string path) { - if (path != null) - { - CheckArgument.Empty (path); - CheckArgument.WhitespaceOnly (path); - CheckArgument.PathChars (path); - - if (path.Length > 0) - { - int nLast = path.LastIndexOfAny (PathSeparatorChars); - if (nLast == 0) - nLast++; - - if (nLast > 0) - return path.Substring (0, nLast); - else - return String.Empty; - } - } - return path; + if (path == null || path == "" || GetPathRoot (path) == path) + return null; + + CheckArgument.WhitespaceOnly (path); + CheckArgument.PathChars (path); + + int nLast = path.LastIndexOfAny (PathSeparatorChars); + if (nLast == 0) + nLast++; + + if (nLast > 0) + return path.Substring (0, nLast); + + return String.Empty; } public static string GetExtension (string path) |