Platform SDK: Win32 API

Long File Names and the Protected-Mode FAT File System

The protected-mode FAT file system is the default file system used by Windows 95/98 for mass storage devices, such as hard disk and floppy disk drives. Protected-mode FAT is compatible with the MS-DOS FAT file system, using file allocation tables and directory entries to store information about the contents of a disk drive. Protected-mode FAT also supports long file names, storing these names as well as the date and time that the file was created and the date that the file was last accessed in the FAT file system structures.

The protected-mode FAT file system allows file names of up to 256 characters, including the terminating null character. In this regard, it is similar to NTFS, the file system that allows file names of up to 256 characters. Protected-mode FAT allows directory paths (excluding the file name) of up to 246 characters, including the drive letter, colon, and leading backslash. This limit of 246 allows for the addition of a file name in the standard 8.3 format with the terminating null character. The maximum number of characters in a full path, including the drive letter, colon, leading backslash, file name, and terminating null character, is 260.

When an application creates a file or directory that has a long file name, the system automatically generates a corresponding alias for that file or directory using the standard 8.3 format. The characters used in the alias are the same characters that are available for use in MS-DOS file and directory names. Valid characters for the alias are any combination of letters, digits, or characters with ASCII codes greater than 127, the space character (ASCII 20h), as well as any of the following special characters.

$ % ' - _ @ ~ ` ! ( ) { } ^ # &

The space character has been available to applications for file names and directory names through the functions in current and earlier versions of MS-DOS. However, many applications do not recognize the space character as a valid character, and the system does not use the space character when it generates an alias for a long file name. MS-DOS does not distinguish between uppercase and lowercase letters in file names and directory names, and this is also true for aliases.

The set of valid characters for long file names includes all the characters that are valid for an alias as well as the following additional characters.

+ , ; = [ ]

Windows 95/98 preserves the case of the letters used in long file names. However, the protected-mode FAT file system, which is not case sensitive, will not allow more than one file to have the same name except for case in the same directory. For example, files named Long File Name and long file name are not allowed to exist in the same directory. Although extended ASCII characters (characters with ASCII codes greater than 127) are also permitted in file names, programs should avoid them, because the meanings of the extended characters may vary according to code page. On disk, the characters in the alias are stored using the OEM character set of the current code page, and the long file name is stored using Unicode format.

Although the protected-mode FAT file system is the default file system in Windows 95/98, it is not the only file system accessible to applications running with Windows 95/98. For example, applications that connect to network drives may encounter other file systems, such as NTFS. Before using long file names for files and directories on a volume in a given drive, you must determine the maximum lengths of file names and paths by using Get Volume Information (Interrupt 21h Function 71A0h function returns values that you can use to make sure your file names and paths are within the limits of the file system.

In general, you should avoid using static buffers for file names and paths. Instead, you should use the values returned by Get Volume Information to allocate buffers as you need them. If you must use static buffers, you should reserve 256 characters for file names and 260 characters for paths. These are the maximum sizes currently recommended for Win32-based applications.