[Mono-list] Simple code - differences in outputbetweenmono & .Net
Nick Berardi
nberardi@zigamorph.com
Wed, 3 Mar 2004 14:11:08 -0500
Windows specific or not. All that it does is call External DLL's. So
unless you know of a better way to do it in managed code this is probably
going to be the best bet for the IO stuff, where a file needs to be created
or deleted or a folder needs to be created or deleted.
Also on the MacOS X thing. We are not looking for the root drive for this
method we are looking for all logical drives, granted in Linux it is only a
/. But if there are 5 drives displayed on MacOS X to the user, then you
have to display all of those drives.
-----Original Message-----
From: Ben Maurer [mailto:05mauben@hawken.edu]
Sent: Wednesday, March 03, 2004 2:01 PM
To: mono-list@lists.ximian.com; nberardi@zigamorph.com
Subject: RE: [Mono-list] Simple code - differences in outputbetweenmono &
.Net
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]
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.
Anybody on the list disagree?
_____
From: jonathan.cooper@syntegra.com [mailto:jonathan.cooper@syntegra.com]
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
Ah, that would explain it.
Shall I continue with the bug submission?
-----Original Message-----
From: Nick Berardi [mailto:nberardi@zigamorph.com]
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:
[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: 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
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 - Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list