5.1.1 System Organization

A volume is a storage device, such as a fixed disk or floppy disk, that is formatted to store files and directories. Each volume has a root directory. Files and subdirectories on the volume are organized in a tree that starts at the root directory. Each directory entry identifies the name, attributes, location, and size of a file or subdirectory.

A large volume can be divided into more than one logical volume, which is also called a partition. Each partition appears to the user, and to the operating system, as a separate volume.

A file system is operating-system software that manages the low-level organization of files on a volume. Win32 supports the following file systems: FAT (file allocation table file system), HPFS (high-performance file system), and NTFS (New Technology file system). The file system defines the filename conventions on a volume, and may also provide file-system-specific features, such as security, recoverability, and high input/output performance. Each volume can use a different file system.

For more specific information on FAT, HPFS, and NTFS, see Chapter 6, “File Systems.”

The first time a volume is accessed by a Win32 file function and whenever a volume is placed in a floppy-disk drive, Win32 examines the volume to determine which file system is appropriate. After that, Win32 manages all input and output to that volume through the dynamic-link library that supports the file system. If an error occurs, the library returns the error to Win32, which then passes it back to the application.

The Win32 file functions enable applications to access files regardless of the underlying file system. However, their functionality may vary depending on the operating system in use. For example, the CreateFile function includes a security parameter that will not provide any security benefits for a Win32 application running on current versions of MS-DOS.

The Win32 file functions identify files and directories by their names. These functions store or search for the file or directory in the current directory on the current disk drive unless the name explicitly specifies a path to a different directory and/or disk drive.

5.1.1.1 Filename Conventions

Although each file system can have specific rules about how individual components in a directory or filename are formed, all file systems follow the same general conventions for combining components. For example, although the FAT file system requires that file and directory names have the 8.3 filename format, and HPFS and NTFS allow names to be any length, all three file systems use the backslash (\) character to separate directory names and the filename when forming a path.

When creating names for directories and files or when processing names supplied by the user, an application should follow these general rules:

Process a path as a null-terminated string. An application can determine maximum length for a path by using the GetVolumeInformation function.

Use any character in the current code page for a name, but do not use a path separator, a character in the range 0 through 31, or any character explicitly disallowed by the file system. A name can contain characters in the extended character set (128–255).

Compare names without regard to case. Names such as ABC, Abc, and abc are considered to be the same.

Use the backslash (\) and/or the forward slash (/) to separate components in a path. No other character is accepted as a path separator.

Use a period (.) as a directory component in a path to represent the current directory.

Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory.

Use a period (.) to separate components in a directory name or filename. Unless explicitly defined by a file system, no restrictions apply to the number of components in a name.

Do not use the following characters in directory names or filenames, because they are reserved for Win32:

< > : " / \ |