[fpc-pascal] DoDirSeparators and special filenames on Windows

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Sep 8 10:44:23 CEST 2013


Am 2013-09-07 21:46, schrieb Bart:
 > On 9/7/13, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
 >> Of course! Why the hell should there be double pathdelims? And why
 >> (silently) accept them as if they were one?
 > There should not be, but (history: DOS and) WinApi accept them, so the
 > are NOT illegal in normal filenames.

In my many decades of MS experience I never have seen double path delimiters anywhere. How do you generate them? I would not know how to do it. And I doubt that all WinAPI function except such (and silently drop one delimiter in the background).


 >> Illegal characters should be taken just like that: Illegal characters. Why
 >> should they be accepted/converted? Who adds illegal characters and expects
 >> them to be silently converted to something legal? Just the opposite.
 > They ('/','.') are only illegal in the '\\?\ scheme, they are
 > perfectly legal (but are converted by WinApi) in "normal" filenames.

That's not true. An extract from http://msdn.microsoft.com/en-us/library/aa365247.aspx says:

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
.....
The following reserved characters:
< (less than)
 > (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
.....


Regarding relative paths: It would be easy to make an exception if the path starts with dots followed by a backslash (on Windows) in which case no '\\?\' prefix would be added. Still for full paths it *should* be added (if it does not yet exist). This way a path would be usable with and without the prefix even if it is longer than MAXPATH.




More information about the fpc-pascal mailing list