canonicalize-path:   Filesystem Path Canonicalization
1 Introduction
2 Interface
canonicalize-path
3 Known Issues
4 History
5 Legal
1:0

canonicalize-path: Filesystem Path Canonicalization🔗ℹ

Neil Van Dyke

1 Introduction🔗ℹ

This package provides the canonicalize-path procedure, which takes a filesystem path and determines a “canonical” equivalent. The canonical path is cleansed, simplified, case-normalized, and complete, and all symbolic links have been followed.
For example, say that you have a Unix filesystem directory structure like (where “->” denotes a symbolic link):

    /tmp/

    |-- a/

    |   |-- b1/

    |   |   `-- s -> ../b2/c/f

    |   `-- b2/

    |       `-- c/

    |           `-- f

    `-- x/

        `-- y -> ../a

If your current directory is then "/tmp/x", you get the following behavior:

> (canonicalize-path "y/b1/s")

  #<path:/tmp/a/b2/c/f>
This is mostly intended for Unix-like filesystems, like on GNU/Linux.
This code was originally written for the RackOut appliance.

2 Interface🔗ℹ

procedure

(canonicalize-path path)  path?

  path : path-string?
Returns a “canonicalized” path to the same file or directory that path would reach. If a cycle is detected while following symbolic links, an exception is raised.

3 Known Issues🔗ℹ

4 History🔗ℹ

5 Legal🔗ℹ

Copyright 2012, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.