Re: [boost] Windows invalid chars in file names

Bronek Kozicki wrote:
Yitzhak Sapir wrote:
this article is obsolete and does not refer to any current version of Windows. Any national characters can be used in a filename. For details see: http://msdn.microsoft.com/library/en-us/fileio/fs/naming_a_file.asp
Obviously, your article does not mention question mark and asterisk. Those are understandably invalid characters in the middle of the filename. Apparently, some UNC names can have a ? At the appropriate place in the filename. But this does not mean that all or most "?" characters are valid. Furthermore, even if the article is obsolete for new versions of Windows, the filesystem is expected to cover all or as many as possible versions.
with a question mark or asterisk. Also, the implementation seems to attempt to validate any name unless it has these characters whereas it could use a "valid list" like the unix implementation does.
there is no "valid list" on current versions of Windows. There is only a small number of characters that cannot be used in filenames and that's it. The article you are refering to does not apply to current versions of Windows.
I quoted one article that dealt with up to NT versions, and one that dealt with Windows 2000. The XP system I use does not allow "?" in the middle of the filename (it returned error code 123).
"CreateFile(filename, GENERIC_READ, 0, NULL,
... and trigger implicit conversions from some random 8-bit codepage to internal Unicode representation? I'd much more prefer if programmers use directly Unicode variants of Windows API (eg. CreateFileW ), or at least be aware of conversions they DO NOT control taking place.
Yes, I should have used CreateFileW rather than CreateFile in that comment. The idea is that the only way to identify all possible legal file names, may be to use the CreateFileW function itself. Yitzhak Sapir

Yitzhak Sapir <yitzhak.sapir@actimize.com> wrote:
Any national characters can be used in a filename. For details see: http://msdn.microsoft.com/library/en-us/fileio/fs/naming_a_file.asp
article is obsolete for new versions of Windows, the filesystem is expected to cover all or as many as possible versions.
which one of many Windows filesystems the Boost.Filesystem library implementation should depend on? Question mark is disallowed in the current version of NTFS, but what about FAT or other filesystems attached via IFS (eg. http://www.fs-driver.org/ )? The same point applies to other platforms. It is not library's job to judge which name is valid and which one is not, unless there are some well-documented platform specific limitations. And the link above points to those. The rest is what exceptions are for.
I quoted one article that dealt with up to NT versions, and one that dealt with Windows 2000. The XP system I use does not allow "?" in the middle of the filename (it returned error code 123).
it does not mean much, unless you try all more or less current versions of Windows with all filesystems they can work with - including those implemented by 3rd parties (just like Ext2 IFS above).
The idea is that the only way to identify all possible legal file names, may be to use the CreateFileW function itself.
Yes and no - there are platform specific limtations that apply to any filesystem attached to the machine you run your program on, and there are also filesystem specific limitations. I have nothing against library enforcing platform specific limitations, however it should not try to enforce limitations that not always apply - instead just go and try to create the file, and report error (presumably via exception) if that fails. B. -- Remove -trap- when replying. Usun -trap- gdy odpisujesz.
participants (2)
-
Bronek Kozicki
-
Yitzhak Sapir