[Mono-dev] Incorrect Directory.GetParent behavior
Emery Conrad
econrad at vt.edu
Wed Apr 26 09:54:48 EDT 2006
Gonzalo,
Hmmm, you are correct. Then the issue is that Directory.GetParent shouldn't
return new DirectoryInfo(Path.GetDirectoryName(path))
when the path is a file in the current directory. Other relative paths work
fine, since they contain actual information about the directory (such as
"../hello.cs"). I submitted a test case and a bug fix (a diff for
System.IO/Directory.cs)
at bugzilla, bug #78209.
Emery
On 4/25/06, Gonzalo Paniagua Javier <gonzalo at ximian.com> wrote:
>
> On Mon, 2006-04-24 at 12:20 -0400, Emery Conrad wrote:
> > Hi there,
> >
> > Directory.GetParent should return a DirectoryInfo for *both* full path
> > names and relative path names. (See
> >
> http://msdn2.microsoft.com/en-us/library/system.io.directory.getparent.aspxfor microsoft doc). Here's the issue: currently, mono implements
> Directory.GetParent using new DirectoryInfo(Path.GetDirectoryName(path)),
> but Path.GetDirectoryName *does not* returns an absolute directory name
> for a relative path (it returns the String-based relative path information
> contained in the argument). So, when mono calls "new DirectoryInfo(relpath)"
> for some relative path, it works UNLESS the Path.GetDirectoryName() has
> return String.Emtpy (since this is the required behavior for this function
> for a relative path of something in the current directory).
> >
> > The fix is to make the ctor for DirectoryInfo reset the argument to
> > Directory.GetCurrentDirectory() when the argument is String.Emtpy.
> > Diff is below.
>
> The problem is that on MS, when you do 'new DirectoryInfo ("")' it
> fails.
>
> Can you provide a test case or a bug report through bugzilla that
> reproduces the issue?
>
> -Gonzalo
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
--
Emery Conrad
Department of Mathematics
Virginia Tech
5076 Derring Hall
Blacksburg, VA 24061-0406
(540) 231-3324
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060426/8c879a7a/attachment.html
More information about the Mono-devel-list
mailing list