You are looking at historical revision 12292 of this page. It may differ significantly from its current revision.

filepath

Description

The filepath library contains procedures for cross-platform parsing and manipulation of file paths. It supports both Windows and POSIX paths, including Windows share paths.

Library Procedures

Platform Flags

[procedure] (filepath:posix [BOOL]) => BOOL

If invoked without arguments, this procedure returns whether the library procedures assume POSIX-style paths or not. Invoking the procedure with a boolean argument disables or enables POSIX-style paths. If set to false, the library procedures assume Windows-style paths.

[procedure] (filepath:is-windows?) => BOOL

Convenience function that returns the inverse of (filepath:posix).

[procedure] (filepath:is-posix?) => BOOL

Convenience function that returns the result of (filepath:posix).

Path Separators

[procedure] (filepath:path-separator) => CHAR

The character that separates directories. On platforms where more than one character is possible, this procedure returns the default one.

[procedure] (filepath:path-separator-set) => CHAR-SET

The set of all possible path separator characters.

[procedure] (filepath:is-path-separator? CHAR) => BOOL

A predicate that returns whether the given character is a path separator for the current platform.

[procedure] (filepath:search-path-separator) => CHAR

The character that is used to separate the entries in the PATH environment variable.

[procedure] (filepath:is-search-path-separator? CHAR) => BOOL

A predicate that returns whether the given character can be used a separator in the PATH environment variable.

[procedure] (filepath:ext-separator) => CHAR

The character that is used to separate file extensions.

[procedure] (filepath:is-ext-separator? CHAR) => BOOL

A predicate that returns whether the given character is a file extension separator.

Search Path

[procedure] (filepath:split-search-path STRING) => LIST

Splits a string on the search path separator character.

[procedure] (filepath:get-search-path) => STRING

Returns search path from the OS environment.

Extension procedures

 filepath:split-extension
 filepath:take-extension
 filepath:replace-extension
 
 filepath:drop-extension
 filepath:add-extension

 filepath:has-extension?

 filepath:split-all-extensions
 filepath:drop-all-extensions

 filepath:take-all-extensions

Drive procedures

filepath:split-drive

filepath:join-drive

filepath:take-drive

filepath:has-drive?

filepath:drop-drive

filepath:is-drive?

Operations on a file path

filepath:split-file-name

filepath:take-file-name

filepath:replace-file-name

filepath:drop-file-name

filepath:take-base-name

filepath:replace-base-name

filepath:take-directory

filepath:replace-directory

filepath:combine

filepath:split-path

filepath:join-path

filepath:split-directories

Trailing Separators

filepath:has-trailing-path-separator?

filepath:add-trailing-path-separator

filepath:drop-trailing-path-separator

File Name Normalization

filepath:normalise

filepath:path-equal?

filepath:make-relative

filepath:is-relative?

filepath:is-absolute?

filepath:is-valid?

filepath:make-valid

Requires

matchable

Version History

License

Based on the Haskell FilePath library by Neil Mitchell.

Copyright 2008 Ivan Raikov.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright

 notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright

 notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.

- Neither name of the copyright holders nor the names of its

 contributors may be used to endorse or promote products derived from
 this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.