Chapter 11. Pathnames

Table of Contents
Functions
Example usage

RScheme provides a pathname abstraction which provides some insulation against the different representation of path names on different operating systems. This facility is only concerned with the naming of files, not with the actual files and directories in the system.

The basic support provided is the notion of a directory, a base filename, and an extension.

The canonical representation is that of Unix pathnames of the general form foo/bar/baz.scm. In this case, foo/bar is the directory, baz is the base filename, and scm is the extension.

If there are multiple periods in the part after the directory, the last separates the filename from the extension (hence the filename part can contain periods). Periods inside directory names are not treated specially.

The directory notion also includes the notion of "up" a directory (the .. directory in unix and MS-DOS.) A canonicalized directory will consist of zero or more "up"s followed by zero or more directory names. The canonicalization process removes occurrences of the form foo/.., so an "up" will never occur in the middle of a directory pathname object.

Functions

Table of Contents
string->file -- Creates a pathname object naming a file
string->dir -- Creates a pathname object naming a directory
pathname->string -- Converts a pathname object to the corresponding string
file-directory -- Accesses the directory part of a pathname
file-within-dir -- Compute the name of the file within it's directory
extension-related-path -- Compute the pathname of a "related" file
append-path -- Append a pathname onto a directory
append-dirs -- Append two directory pathnames.
pathname->os-path -- Converts a pathname object to the corresponding string