April 14th, 2004

Not all short filenames contain a tilde

I’m sure everybody has seen the autogenerated short names for long file names. For the long name “Long name for file.txt”, you might get “LONGNA~1.TXT” or possibly “LO18C9~1.TXT” if there are a lot of collisions. What you may not know is that sometimes there is no tilde at all! Each filesystem decides how it wants to implement short filenames. Windows 95 uses the “~n” method exclusively. Windows NT adds the hexadecimal hash overflow technique. But some filesystems (like Novell) just truncate the name. “Long name for file.txt” on a Novell server will come out to just “LONGNAME.TXT”.

So don’t assume that all short names contain tildes. They don’t. This means no cheating on skipping a call to GetLongFileName if you don’t see any tildes, since your optimization is invalid on Novell networks.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.