[Mono-list] Simple code - differences in output betweenmono & .Net

Ben Maurer 05mauben@hawken.edu
Wed, 03 Mar 2004 14:01:24 -0500


I have never used MacOS X, however, here is what I would suggest:

If it is like linux, where everything starts at a central root (/), give =
the root

If it is like windows, where the drive is the first component of the path, =
give the root component.

Again, I really think that it is up for debate as to what is the `right' =
return. The decision to include this windows specific api in the System =
namespace was not a good one.

-- Ben

>>> "Nick Berardi" <nberardi@zigamorph.com> 03/03/04 13:50 PM >>>
Ben,

How would this work in MacOS X, I have never used it but with the old
MacOS's they gave you the drives that were available on the machine.  =
Would
there have to be a custom mapping for that?

-----Original Message-----
From: Ben Maurer [mailto:05mauben@hawken.edu]=20
Sent: Wednesday, March 03, 2004 1:44 PM
To: mono-list@lists.ximian.com; jonathan.cooper@syntegra.com;
nberardi@zigamorph.com
Subject: RE: [Mono-list] Simple code - differences in output betweenmono &
.Net

Remember, this says "logical" drives, not "physical". In windows, logical
drives are the ones assigned a,b,c,d,e... (Take a look at the WinAPI
GetLogicalDrives function, it just returns a bitmask representing each
drive).

The GetLogicalDrives function in C# has one very special property that we
would override if we were to go with the "show the mounts method":
There is no relative path that can connect two logical drives, assuming =
they
are distinct drives.

Also, note the following remark in GetPathRoot:
"The .NET Framework does not support direct access to physical disks =
through
paths that are device names, such as "\\.\PHYSICALDRIVE0 "."

So, this would sort of say to me not to do mounts.

Another problem with using the mount points would be that Path.GetPathRoot
should always return the string it is passed if you are passing a string
from GetLogicalDrives. We would violate this if we were to do the mount
points.

Really, this method is going to be very broken on a non-windows platform. =
I
would go so far as to say that if you are using it, you are risking your =
app
not being cross platform.

One thing that is wrong about what we are doing is the situation on =
windows.
That is absolutely a bug. However, on Linux I think we are doing the right
thing. IMHO, the only other correct behavior would be to throw an =
exception
that stated the api was Windows specific.

I am also not sure what context someone would use this API in. The only
reason I can think of for using it is some sort of file browser. However,
this is an application i would generally think of as platform bound =
anyways.
It would be a bit easier to comment about the correct behavior with a use
case. I am not sure what a file browser shoudl display. On the one hand,
having a single root, /, is pretty correct (nautilus does it), however, a
root for each drive would be more user friendly. One problem is that on
Windows, the drive logical name and the physical drive are very much
associated, you say "open up the C drive" or "copy that to the A drive". =
So,
in Windows, it is user friendly to display "D:\" as the name of the cdrom.
However, a user would *not* say "open up /mnt/cdrom" I think showing
/mnt/cdrom as a root would actually be wrong.

Maybe a use case will make me change my minde about "/" being the correct
return.

As a side note, this api was put in the wrong place. It should really be =
in
a Microsoft.Windows namespace. Sigh.

>>> "Nick Berardi" <nberardi@zigamorph.com> 03/03/04 10:13 AM >>>
I guess logical drives in Linux is just the root.  But I would think that
they would include the mount points in here?  Don't you think?  Because
basically that is all that a Windows Drive is.  A mounted partition.

=20

Anybody on the list disagree?

=20

  _____ =20

From: jonathan.cooper@syntegra.com [mailto:jonathan.cooper@syntegra.com]=20=

Sent: Wednesday, March 03, 2004 9:57 AM
To: nberardi@zigamorph.com; mono-list@lists.ximian.com
Subject: RE: [Mono-list] Simple code - differences in output between mono =
&
.Net

=20

Ah, that would explain it.

=20

Shall I continue with the bug submission?

-----Original Message-----
From: Nick Berardi [mailto:nberardi@zigamorph.com]=20
Sent: 03 March 2004 14:55
To: COOPER, Jonathan -Syntegra UK; mono-list@lists.ximian.com
Subject: RE: [Mono-list] Simple code - differences in output between mono =
&
.Net

I was right here is your problem:

=20

=20
                [MonoTODO("Implement on windows, for real")]
                public static string[] GetLogicalDrives ()
                {=20
                        //FIXME: Hardcoded Paths
                        if ((int)Environment.OSVersion.Platform =3D=3D =
128)
                                return new string[] { "/" };
                        else
                                return new string [] { "A:\\", "C:\\" };
                }

=20

=20


  _____ =20


From: mono-list-admin@lists.ximian.com
[mailto:mono-list-admin@lists.ximian.com] On Behalf Of
jonathan.cooper@syntegra.com
Sent: Wednesday, March 03, 2004 9:32 AM
To: mono-list@lists.ximian.com
Subject: [Mono-list] Simple code - differences in output between mono & =
.Net

=20

I have code (at the end of this message) in a .cs file, compiled with mcs
and csc on Windows XP. When compiled with either compiler the executable
works on both runtimes (.Net and mono). However, the output is different.

Run under .Net:=20
------------------------=20
Disk:  A:\=20
Disk:  C:\=20
Disk:  D:\=20
Disk:  K:\=20
Disk:  L:\=20
Disk:  Q:\=20
Disk:  T:\=20
Disk:  U:\=20
Disk:  X:\=20
c:\=20
Dir:  c:\Compaq=20
Dir:  c:\Config.Msi=20
Dir:  c:\Documents and Settings=20
Dir:  c:\Program Files=20
Dir:  c:\RECYCLER=20
Dir:  c:\System Volume Information=20
Dir:  c:\WINNT=20

=20

Basically the contents of the root c:\ drive=20

Run under mono:=20
--------------------------=20
Disk:  A:\=20
Disk:  C:\=20
c:\=20
>> a list of directories in the current directory rather than the root c:\
<<=20

Is this due to an incomplete feature, or am I missing something?=20

Thanks in advance,=20
Jon Cooper=20

=20

------------------------ CODE in drives.cs ------------------------=20

using System;=20
using System.IO;=20

namespace test=20
{=20
   class test=20
   {=20
      [STAThread]=20
      static void Main(string[] args)=20
      {=20
         string[] s =3D Directory.GetLogicalDrives();=20
         foreach(string drive in s)=20
            Console.WriteLine("Disk:  {0}",drive);=20

         string mydrive =3D Console.ReadLine();=20

         if(mydrive.Length !=3D 0)=20
         {=20
           foreach(string d in Directory.GetDirectories(mydrive))=20
              Console.WriteLine("Dir:  {0}",d);=20

           Console.Read();  //pause=20
         }=20
      }=20
   }=20
}=20



********************************************************************

This email may contain information which is privileged or confidential. If
you are not the intended recipient of this email, please notify the sender
immediately and delete it without reading, copying, storing, forwarding or
disclosing its contents to any other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************



********************************************************************

This email may contain information which is privileged or confidential. If
you are not the intended recipient of this email, please notify the sender
immediately and delete it without reading, copying, storing, forwarding or
disclosing its contents to any other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************



_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list