Liviu wrote:From the horse's mouth: <snip: only two links allowed>
- "All file systems follow the same general naming conventions for an individual file: a base file name and an optional extension, separated by a period" - which implies that the name is mandatory, the extension optional.
- "However, it is acceptable to specify a period as the first character of a name. For example, ".temp"." - which implies that ".temp" is the name.
I think, you misunderstood the purpose of the linked document.
The underlying file system (NTFS, FAT12/16, ...) and the Win32 file API both have definitions of how a filename is defined.
The file systems (only) define a filename as a base file name with an optional extension.
The Win32 file API is written as common as possible, so it also allows nearly any non empty String as a filename:
If the underlying filename does support it, you may create a file named "." (had to delete it by using a backup... impossible to delete that using the Win32 file API...).
The filename is simply split at the last '.' character into the base filename and the extension.
But i'm not sure if the dot belongs to the base name, the extension, or to none of them:
I've seen all versions and no documentation about that, so you still could be right if the definition somewhere says that the Win32 file API defines it in the same way, but i doubt it (or it were the worst implementation ever).
For example dot belongs to the extension (although this isn't the Win32 file API):
Code: Select all
Z:\>>.c echo a
Z:\>>c.c echo a
Z:\>@for %a in (*.c) do @echo "%~na" "%~xa"
"" ".c"
"c" ".c"
To have no problem with whatever file system Microsoft has created the "Naming Conventions": Lets name them "windows shell Conventions".
So the first part ("All file systems follow the...") describes the filesystem convention,
while the second part ("However, it is acceptable to specify a...") is a part of the windows shell Conventions.
So you cannot derive that ".temp" is the name because it depends on the file system, while ".temp" is the Win32 API representation of the file name.
I prefer using the "windows shell naming convention" in this forum, because batch can't directly access/manipulate the file system/win32 API.
Liviu wrote:That said, names like ".temp" are uncommon in Windows, and have always been confusing even to Microsoft's own. For example, one of the well respected MSDN blogs offers the following, which directly contradicts the formal spec:
http://blogs.msdn.com/b/oldnewthing/archive/2008/04/14/8389268.aspx -
"Such files are considered to have an extension but no name."
This may be no contradiction if Microsoft has defined it that way within the Win32 API.
(Although i've never seen such a definition... but i've read something like that multiple times, which is on the other hand no proof at all.)
@dbenham
Finally i'm sad to say, that i've found out (accidentally), that XP behaves... exotic:
Code: Select all
Z:\>dir /x
Datenträger in Laufwerk Z: ist Test
Volumeseriennummer: 0438-EEA7
Verzeichnis von Z:\
25.01.2015 18:04 <DIR> .
25.01.2015 18:04 <DIR> ..
0 Datei(en) 0 Bytes
2 Verzeichnis(se), 133.163.368.448 Bytes frei
Z:\>> 12345678.1234 echo a
Z:\>> .c echo a
Z:\>dir /X
Datenträger in Laufwerk Z: ist Test
Volumeseriennummer: 0438-EEA7
Verzeichnis von Z:\
25.01.2015 17:41 <DIR> .
25.01.2015 17:41 <DIR> ..
25.01.2015 17:41 3 C36E2~1 .c
25.01.2015 17:41 3 123456789.1234
2 Datei(en) 6 Bytes
2 Verzeichnis(se), 133.163.368.448 Bytes frei
Z:\>fsutil behavior query disable8dot3
disable8dot3 = 1
If i use a disk editor to change the short name to null, then the 'dir "<"' command doesn't list the ".c" file anymore.
So the behaviour of 'dir "<"' is not really an exception.
penpen
Edit: Added "@dbenham" to better divide sections.