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" <[EMAIL PROTECTED]> 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. Anybody on the list disagree? _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 03, 2004 9:57 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [Mono-list] Simple code - differences in output between mono & .Net Ah, that would explain it. Shall I continue with the bug submission? -----Original Message----- From: Nick Berardi [mailto:[EMAIL PROTECTED] Sent: 03 March 2004 14:55 To: COOPER, Jonathan -Syntegra UK; [EMAIL PROTECTED] Subject: RE: [Mono-list] Simple code - differences in output between mono & .Net I was right here is your problem: [MonoTODO("Implement on windows, for real")] public static string[] GetLogicalDrives () { //FIXME: Hardcoded Paths if ((int)Environment.OSVersion.Platform == 128) return new string[] { "/" }; else return new string [] { "A:\\", "C:\\" }; } _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, March 03, 2004 9:32 AM To: [EMAIL PROTECTED] Subject: [Mono-list] Simple code - differences in output between mono & .Net 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: ------------------------ Disk: A:\ Disk: C:\ Disk: D:\ Disk: K:\ Disk: L:\ Disk: Q:\ Disk: T:\ Disk: U:\ Disk: X:\ c:\ Dir: c:\Compaq Dir: c:\Config.Msi Dir: c:\Documents and Settings Dir: c:\Program Files Dir: c:\RECYCLER Dir: c:\System Volume Information Dir: c:\WINNT Basically the contents of the root c:\ drive Run under mono: -------------------------- Disk: A:\ Disk: C:\ c:\ >> a list of directories in the current directory rather than the root c:\ << Is this due to an incomplete feature, or am I missing something? Thanks in advance, Jon Cooper ------------------------ CODE in drives.cs ------------------------ using System; using System.IO; namespace test { class test { [STAThread] static void Main(string[] args) { string[] s = Directory.GetLogicalDrives(); foreach(string drive in s) Console.WriteLine("Disk: {0}",drive); string mydrive = Console.ReadLine(); if(mydrive.Length != 0) { foreach(string d in Directory.GetDirectories(mydrive)) Console.WriteLine("Dir: {0}",d); Console.Read(); //pause } } } } ******************************************************************** 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 - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
