[Mono-dev] DriveInfo implementation
lordhabbit at gmail.com
Thu Dec 6 09:30:40 EST 2007
Robert Jordan wrote:
>The PLATFORM_WIN32 conditional in icall.c must be avoided.
>Since you're going to implement GetDiskFreeSpaceEx in io-layer
>it will be not necessary. But I guess you already know this
>and tried to keep the code compilable, correct?
Er, no. At the time I wrote that code I was in doubt. I didn't know if
I would take the Win32+iolayer way (which seems the most probable now)
or the ifdef+posix way (which is used in other icalls like the ones
from System.Environment). The first way seems cleaner at first, but
the second avoids double marshaling of strings (first to utf16 at the
icall for the win32 API, then to utf8 at io-layer for the POSIX call).
Also, as you said, I wanted my patch to keep the SVN tree compilable
on all supported platforms. So, when I get to the posix port, I will
either remove that #ifdef or fill the #else case.
>Also, do not use g_assert if you already thrown an exception.
>This will kill the runtime.
Ok, so I'm leaving the checks code as exceptions, not as assertions.
By the way, does the unmanaged method return immediately when an
exception is raised or does it need to actually execute a "return"?
>On DriveInfo.diff: we all know about the
>"if (platform == 4 || platform == 128)" trick. There is no
>need to comment it like this :-)
>Since you're in corlib, you should use the internal property
That was not my code, I only added the comment. Besides, I think that
particular check should be right since a newer .NET FW (3.5, I
believe) adds a PlatformID for the Xbox 360, and, in general, for
future compatibility, you should always check for what you want, not
for !everythingelse. IsRunningOnWindows was appropiate (and I used it)
in the modifications i made to the constructor.
Conclusion: since all the fuss is about two coments (one about
assertions in icall.c and one about the Unix PlatformID hack in
DriveInfo.cs), I'm too lazy to submit an updated patch just for that
u_u. I'll remove them (if noone does it first) when I submit the posix
More information about the Mono-devel-list