|
|
The library described in this paper models UNIX path names by the single class Path. For example, the Path
Path p("foo/bar/baz");
represents the above path. In the library, Paths are always kept in canonical form. In canonical form, ``.'' components are removed, (except for the Path ``.'' itself, which is the relative Path representing the working directory), ``..'' components are collapsed where possible (i.e., other than in an initial ``..'' series in a relative Path), multiple consecutive '/'s are reduced to a single '/', and trailing '/'s are removed. Thus, for example, the statement
cout << Path("../x///a/../b/");
will print out ``../x/b''. This canonicalization is always done behind the scenes; there is never a need for the user to explicitly invoke a canonicalization routine. String(3C++) can be used if the user needs to save the value of a Path in non-canonical form.)
Where it makes sense to do so, the behaviors of the functions in the Path library match the behaviors of the corresponding functions in the Korn shell.
Notice that the user need not be running the Korn shell in order for this to occur; in particular, even if the user is running another shell, the behavior of the Path library will still match that of the Korn shell.