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

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):


    |-- 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")

This is mostly intended for Unix-like filesystems, like on GNU/Linux.
This code was originally written for the RackOut appliance.

2 Interface


(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 for details. For other licenses and consulting, please contact the author.