[Mono-dev] DriveInfo implementation

Robert Jordan robertj at gmx.net
Tue Dec 4 08:14:50 EST 2007


Javier Martín wrote:
> Hi all,
> 
> I would like to help in the implementation of the System.IO.DriveInfo
> class, which as of now is semi-functional in Linux and little more
> than a stub in Windows. However, after thinking a bit about it, I've
> come to the conclusion that the methods that discover the volumes in
> the system (*GetDrives) require P/Invoke at the very least (windows),
> and possibly even unmanaged code (linux).

This is already implemented: Environment.GetLogicalDrives ().

> The point of this message is asking for directions and rules on this
> matter. Is unmanaged code (at all) allowed? Can I create a portable
> "interface" (not necessarily a .NET interface) and then a separated,
> system-dependant implementation? How are those platform-dependant
> switches managed in the Mono autoconf files? Etcetera.

Just follow the trails of Environment.GetLogicalDrives ()'s
implementation. You'll find out it is an internal call,
implemented in mono/metadata/icall.c, based on
GetLogicalDriveStrings, a Windows API. On Unix, this API is
emulated in mono/io-layer/.
This is the place you can add other I/O related
Windows API calls you might need to complete DriveInfo.

Robert




More information about the Mono-devel-list mailing list