[Mono-list] Platform comparison

Jonathan Gilbert 2a5gjx302@sneakemail.com
Tue, 09 Mar 2004 02:02:01

Like I said, Explorer does not support *renaming* a file so that it begins
with a dot :-) It is a bug in the SHRenameFile function. I debugged it a
while back. Though I have not investigated the source code (I don't even
know if it's part of the code that got leaked), the beginning of the
function has something much like this (my own code):

int SHRenameFile(char *lpFromFilename, char *lpToFilename)
  if ((lpToFilename[0] == 0) || (lpToFilename[0] == '.'))
    return E_NOFILENAME;

..thus popping up a "You must enter a filename." dialog box. My theory is
that they are defending against the case where, with extensions hidden,
someone empties the input box. Of course, the extension will be added back
on, leaving ".txt" for instance as the filename. It didn't occur to
Microsoft that perhaps people might want legitimate filenames starting with
dots, such as ".NET Performance Analysis.doc". In light of this particular
bug, ".NET" was perhaps not the best choice of names for their new
technology :-)

As for support of the slash, yes, of course Mono will have to translate
'\\' into '/' for the sake of users doing this:
  string path = a + '\\' + b;
instead of this:
  string path = Path.Combine(a, b);
or at least this:
  string path = a + Path.DirectorySeparatorChar + b;

..and considering that the docs state both of the following explicitly,
mono's implementation is not just appropriate but in fact mandatory.

1. The AltDirectorySeparatorChar is set to '\\' under Unix. Does this apply
only to their implementation? I don't think it does.
2. Both can be used as separators in paths.

This raises some other issues. If the mono implementation is as above (and
I assume it most likely is, as the documentation really isn't that hard to
decipher), then is mono *incapable* of accessing files whose names embed


At 11:23 AM 08/03/2004 -0500, you wrote:
>Explorer does support a file beginning with a ".", because there are some
>Unix files that I have downloaded and it starts with ".", and Explorer reads
>it fine, the problem is there seems to be an method in Explorer that
>specifically doesn't allow it starting with a "." when creating the file.  
>Also I didn't know about that AltPath Property.  Either way I think that all
>majic numbers or strings should be eliminated in most cases, that is why I
>always use String.Empty, Environment.NewLine, and String.Concat(...).  So
>just practice good coding and you shouldn't run into any problems.  
>Also don't you think if the Win32 API supports either slash that mono should
>do the same, so that it mimics the real .Net as much as possible?  
>-----Original Message-----
>From: mono-list-admin@lists.ximian.com
>[mailto:mono-list-admin@lists.ximian.com] On Behalf Of Jonathan Gilbert
>Sent: Tuesday, March 09, 2004 12:58 AM
>To: mono-list@lists.ximian.com
>Subject: RE: [Mono-list] Platform comparison
>Actually, as I understand it, it doesn't do any transformation. It passes
>/'s to the underlying filesystem API, because it is supported there.  Yes,
>the Win32 API *does* support '/' as a path separator character (Explorer's
>support for this is sketchy, though; Explorer has other problems as well,
>such as not allowing you to rename a file so that it begins with a dot).
>Note also that even in Windows, the framework has
>System.IO.Path.AltDirectorySeparatorChar == '/'. I haven't investigate it,
>but the framework documentation implies that Rotor sets this to "\\",
>despite the fact that, to the best of my knowledge, "\\" is not supported
>on Unix as it is a valid character within a pathname component! I quote
>from the AltDirectorySeparatorChar MSDN article:
>The character stored in this field cannot be in InvalidPathChars. This
>field can be set to the same value as DirectorySeparatorChar.
>AltDirectorySeparatorChar and DirectorySeparatorChar are both valid for
>separating directory levels in a path string.
>The value of this field is a backslash ('\') on Unix, and a slash ('/') on
>Windows and Macintosh operating systems.
>At 10:12 AM 08/03/2004 -0500, you wrote:
>>Hi everybody I just wanted to weigh in on this subject.  I have found that
>>in the MS .Net framework, it usually doesn't matter what slash character
>>use, because the framework converts it.  Such as if you are in a HTTP URL
>>the framework converts "\" to "/".  And if you are working with an IO
>>namespace then it converts "/" to "\".  I don't know if Mono does this,
>>because I am just starting to use Mono, but there should be some
>>normalization in the framework so the programmer doesn't constantly have to
>>check these kinds of things IMHO.
>>-----Original Message-----
>>From: mono-list-admin@lists.ximian.com
>>[mailto:mono-list-admin@lists.ximian.com] On Behalf Of Rodolfo Campero
>>Sent: Monday, March 08, 2004 10:00 AM
>>To: jwezel@compumaster.de; mono-list@ximian.com
>>Subject: RE: [Mono-list] Platform comparison
>>Hi Jochen,
>>Instead of hard-coding the separator char, you can use 
>>I don't know any guideline, but in general if you are about to do something
>>that you think is not platform-independent, search a bit because is almost 
>>sure that there is a platform-independent way to do it.
>>>From: "Jochen Wezel" <jwezel@compumaster.de>
>>>To: <mono-list@ximian.com>
>>>Subject: [Mono-list] Platform comparison
>>>Date: Mon, 8 Mar 2004 14:37:41 +0100
>>>Hello together!
>>>Is there a comparison or guideline for the several platforms regarding
>>>what we developers have to pay attention to?
>>>For example, Linux uses "/" as directory separator char, Windows uses
>>>"\", but what about Mac OS (X)?
>>>Or maybe there are other points which are good to know?
>>>Mono-list maillist  -  Mono-list@lists.ximian.com
>>Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
>>Mono-list maillist  -  Mono-list@lists.ximian.com
>>Mono-list maillist  -  Mono-list@lists.ximian.com
>Mono-list maillist  -  Mono-list@lists.ximian.com
>Mono-list maillist  -  Mono-list@lists.ximian.com