[Mono-list] mono bug?: VolumeSeparatorChar (System.IO.Path)
Martin Aliger
martin_aliger@email.cz
Fri, 4 Oct 2002 17:55:16 +0200 (CEST)
Hi all,
this one is pretty serious [and little tricky]. Consider this example:
--------
using System;
using System.IO;
class PathTest
{
static public void Main()
{
Console.WriteLine("{0}",Path.IsPathRooted("bin"));
Console.WriteLine("{0}",Path.IsPathRooted("/bin"));
Console.WriteLine("{0}",Path.IsPathRooted("./bin"));
}
}
--------
What it could write? I hope "False/True/False". It looks logical as well.
BUT now it returns "False/True/True" ! Problem is digged in VolumeSeparatorChar, which is '/' on Linux. IsPathRooted uses this condition:
char c = path [0];
return (c == DirectorySeparatorChar ||
c == AltDirectorySeparatorChar ||
(path.Length > 1 && path [1] == VolumeSeparatorChar));
and both path.Length>1 and path[1]='/' is true.
Real problem is, that I do not know what MS guys means by setting VolumeSep to '/' on Unixes (as docs says). It makes no sense to me... What about relative paths as "a/b/c/d.exe" ? Full path could be e.g. "/home/alik/mono/a/b/c/d.exe" and everything is ok... I was about to report fix to this as change VolumeSepChar to '\0' (in runtime) but than read MS docs...
Any idea?
Martin
BTW: Is corlib/Linux/Linux.cs file is meaningful? At least there defined VolumeSepChar is not... [should be removed to increase cleanliness]
BTW2: in Path.Combine current implementation the condition "
bool b2 = path2 [0] == DirectorySeparatorChar ||
path2 [0] == AltDirectorySeparatorChar;
" is always true (checked before with IsPathRooted)
______________________________________________________________________________
Domácí spotřebiče a elektronika za akční ceny slevy až 50 %.
Klikněte na: http://www.obchodni-dum.cz/index.phtml?prov=54&akce=yes