This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see PathnamesPython in WG2's repo for R7RS-large.

Pathnames­Python

cowan
2014-11-06 00:23:14
1history
source

Path objects

Path objects represent filesystem paths with semantics appropriate for different operating systems. This proposal is essentially a straight transliteration of the pure portion of the Python `pathlib` library into Scheme. As a result, it does not provide any support for accessing the file system. See also PEP 428.

Path objects are immutable objects of a disjoint type. They are divided into two subtypes, Posix paths and Windows paths. Most procedures in this proposal operate correctly on both subtypes.

Every path object has a drive, a root, and a possibly empty sequence of components, all of which are strings. The drive of a Posix path object is always the empty string; on Windows it can be a drive letter or device name followed by a colon, or a string of the form //host/share when the path object was created from an UNC pathname. The root is the empty string for a relative path, "/" for an absolute path, or exceptionally "//" in path objects representing Posix pathnames beginning with // (whose meaning is system-dependent).

Constructors

(make-posix-path string)

(make-windows-path string)

(make-path string)

Invokes make-posix-path on non-Windows systems and make-windows-path on Windows systems.

Predicates

(path? obj)

(posix-path? obj)

(windows-path? obj)

(path-absolute? path)

(path-reserved? path)

Accessors

(path-drive path)

(path-root path)

(path-anchor path)

(path-parent path)

(path-filename path)

(path-suffix path)

(path-suffixes path)

(path-stem path)

(path-base path)

Conversion

(path->string path)

(path->slashed-string path)

(path->file-uri path)

(path->file-iri path)

Path operations

(path-join string-or-path1 string-or-path2 ...)

(path-match path glob-string)

(path-relative-to path1 path2)

(path-with-name path name)

(path-with-suffix path suffix)