[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Dawkins, David
Subject: [DotGNU]Path.[Alt]DirectorySeparatorChar
Date: Sat, 30 Nov 2002 09:37:43 -0500

I am troubled.

On my Win2000/cygwin installation, the output from this code:

        Console.WriteLine("Dir char is {0} Alt dir char is {1}",
is this:

        Dir char is / Alt dir char is 

The ECMA spec says that for Path.DirectorySeparatorChar:

        The value of this field is a backslash (\) on Windows systems 
        and a slash (/) on Unix systems

It says exactly the same thing for Path.AltDirectorySeparatorChar,
which I think must be wrong (a copy-and-paste typo when writing
the spec perhaps?)

The MS .NET docs for Path.AltDirectorySeparatorChar say:

        The value of this field is a backslash ('\') on Unix, and a 
        slash ('/') on Windows and Macintosh operating systems.

which makes sense to me. You'd use Path.DirectorySeparatorChar
when composing paths, but you'd allow both when parsing
paths (if set).

Somehow I think pnet must have got misconfigured before I built it,
since I can see this in engine/lib_dir.c:

void _IL_DirMethods_GetPathInfo(ILExecThread *thread, void *result)
        Platform_PathInfo *info = (Platform_PathInfo *)result;
#if defined(_WIN32) || defined(WIN32)
        info->dirSeparator = '\\';
        info->altDirSeparator = '/';
        info->volumeSeparator = ':';
        info->pathSeparator = ';';
        info->invalidPathChars = 0;
        info->dirSeparator = '/';
        info->altDirSeparator = 0;
        info->volumeSeparator = 0;
        info->pathSeparator = ':';
        info->invalidPathChars = 0;

So, my questions:

1. Should we make the unix altDirSeparator char be '\' (and
assume that the ECMA contains a mistake).

2. Is there a (nice) way to do a runtime check for OS type so that I 
can unit test these values? (I could detect the presence of certain
environment variables as a nasty nasty hack, but I'd rather
not.. :) 

[ 3.   ... anyone have any idea why WIN32/_WIN32 wasn't set
       when I built pnet? I'll figure it out ]


David Dawkins

reply via email to

[Prev in Thread] Current Thread [Next in Thread]