Home |
Sectors, Sector Addressing, and Clusters Logical Drives and Partition Tables The File Allocation Table and Cluster Sizes Long File Names The ISO 9660 File System Structure The exFAT File System Structure |
Long File NamesInitially, FAT file systems only supported short file names of up to 11 upper case characters with an implicit period between the 8th and 9th character. Long file names with up to 255 characters length were added in 1995. To maintain backward compatibility, the specification of the long file name implementation is rather kludgy. Long file names exist in addition to traditional short file names and are stored in a variable number of hidden short (32 byte) directory entries. Thus, most files actually have two names: a short name and a long name. Within a single directory, all long and short names must be unique. When a file name is passed to an RTFiles-32 API function, RTFiles-32 will search both long names and short names to determine if the file exists on disk, so files can be opened, renamed, queried, etc. by either name. When a new file is to be created, a unique short name is automatically created by RTFiles-32. The comparison of file names is not case sensitive. For example, the name "A Name.txt" and "A NAME.TXT" would both reference the same file on disk. However, when a file is created, the case is preserved. Functions such as RTFGetFileInfoEx, RTFFindFirstEx, and RTFFindNextEx will return the name of the file as it was created. Short names are always converted to upper case before written to disk. Short names can be queried using function RTFMakeFileName. Short file names may consist of any combination of letters, digits, or character values greater than 127. The following special characters are also allowed: $ % ' - _ @ ~ ` ! ( ) { } ^ # & Long file names may consist of all characters defined for short names with the addition of the period "." character used multiple times within the long name. A space is also a valid character in a long name as it always has been for a short name. However, in short names it typically is not used. The following additional special characters are allowed in long names: . + , ; = [ ] They are not legal in short names. While embedded spaces within file names are allowed, leading and trailing spaces are ignored. Long file names need additional space in directories, and directories may need to be searched multiple times to find unique short names, so some overhead may be involved. RTFiles-32 attempts to minimize the added overhead by creating a long file name only when a long file name cannot be represented by a short name. Long names are eliminated for all file names no longer than 8.3 characters and only consisting of upper case characters. In addition, function RTFCompactDir may be used to optimize directories for faster searching. Long file names are stored as Unicode strings on disk, but RTFiles-32's API uses 8-bit ASCII character strings to denote file names. The Unicode mapping (translation of 8-bit ASCII character values to 16-bit Unicode character values) for character values in range 0..127 is one-to-one. The mapping for characters in the range 128 to 255 depends on the active code page. Short file names are always stored on disk using OEM code page 437. Code page 437 is also the default code page used by RTFiles-32's API. Function RTFSetCodePageANSI can switch the API to ANSI code page 1252. Function RTFSetCodePage can be used to install arbitrary code page translation tables. To be able to use the full range of 65536 characters used in long file names, RTFiles-32 also supports UTF-8 encoded file names through function RTFSetCodePageUTF8. UTF-8 is a multi-byte Unicode encoding compatible with 8-bit, NUL terminated strings used in RTFiles-32's API as well as traditional ANSI C/C++ string manipulation functions such as strlen(), strcpy(), strcmp(), etc.
|