[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] Pathnames

See also 11.6.2 Pathname utilities, for high-level APIs.

Function: sys-normalize-pathname pathname &keyword absolute expand canonicalize
Converts pathname according to the way specified by keyword arguments. More than one keyword argument can be specified.
If this keyword arugment is given and true, and pathname is not an absolute pathname, it is converted to an absolute pathname by appending the current working directory in front of pathname.
If this keyword argument is given and true, and pathname begins with `~', it is expanded as follows:
  • If pathname is consisted entirely by "~", or begins with "~/", then the character "~" is replaced for the pathname of the current user's home directory.
  • Otherwise, characters following `~' until either `/' or the end of pathname are taken as a user name, and the user's home directory is replaced in place of it. If there's no such user, an error is signalled.
Tries to remove pathname components "." and "..". The pathname interpretation is done purely in textural level, i.e. it doesn't access filesystem to see the conversion reflects the real files. It may be a problem if there's a symbolic links to other directory in the path.

Function: sys-basename pathname
Function: sys-dirname pathname
sys-basename returns a basename, that is the last component of pathname. sys-dirname returns the components of pathname but the last one. If pathname has a trailing `/', it is simply ignored.
(sys-basename "foo/bar/bar.z") => "bar.z"
(sys-basename "coo.scm") => "coo.scm"
(sys-basename "x/y/") => "y"
(sys-dirname "foo/bar/bar.z") => "foo/bar"
(sys-dirname "coo.scm") => "."
(sys-dirname "x/y/") => "x"
These functions doesn't check if pathname really exists.

Some boundary cases:
(sys-basename "") => ""
(sys-dirname "") => "."

(sys-basename "/") => ""
(sys-dirname "/") => "/"
Note: The above behavior is the same as Perl's basename and dirname. On some implementations, the command basename may return "/" for the argument "/", and "." for the argument ".".

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html