|
|
Before we can describe the UNIX path name library, we have to clarify a few terms.
A UNIX path name, or path for short, is any non-empty character string beginning with an optional slash (/) and followed by zero or more slash-separated components, or file names. If the initial slash is present, it is also considered a component. Thus the components in the path ``/foo/baz/bar'' are ``/'', ``foo'', ``baz'' and ``bar'', while the components in the path ``foo/baz/bar'' are ``foo'', ``baz'' and ``bar''. The path ``/'' consists of the single component ``/'', and the path ``foo'' consists of the single component ``foo''. Paths which begin with a slash are called absolute, otherwise they are called relative.
Every path represents a single file in the underlying file system, but remember that different files can represent the same inode, due to real or symbolic linking. If the path is absolute, the file can be found by starting at the root of the file system and following the file names in the path from left to right down the directory hierarchy. If the path is relative, the file can be found by following the same procedure, but starting at the implicit working directory. Notice, however, that the file represented by a given path need not actually exist in the underlying file system. In other words, a path represents only a possible file; it is up to the user to arrange, if so desired, that the file and all directories leading up to it exist. The Path library provides the functionality which makes this easy to do.
In everyday speech, the terms ``path name,'' ``file name,'' and ``file'' are frequently used interchangeably, but we shall use them with their precise meanings.