chickadee » filepath

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

filepath:posix #!optional BOOLprocedure

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.

filepath:is-windows?procedure

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

filepath:is-posix?procedure

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

Path Separators

filepath:path-separatorprocedure

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

filepath:path-separator-setprocedure

The set of all possible path separator characters.

filepath:is-path-separator? CHARprocedure

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

filepath:search-path-separatorprocedure

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

filepath:is-search-path-separator? CHARprocedure

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

filepath:ext-separatorprocedure

The character that is used to separate file extensions.

filepath:is-ext-separator? CHARprocedure

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

Search Path

filepath:split-search-path STRINGprocedure

Splits a string on the search path separator character.

filepath:get-search-pathprocedure

Returns search path from the OS environment.

Extension procedures

filepath:split-extension PATHprocedure

Splits path on the last extension.

filepath:take-extension PATHprocedure

Returns last extension of given path, or empty string.

filepath:replace-extension PATH EXTprocedure

Replaces the last path extension with the given extension.

filepath:drop-extension PATHprocedure

Removes last extension and extension separator preceding it.

filepath:add-extension PATH EXTprocedure

Appends an extension to the given path.

filepath:has-extension? PATHprocedure

Returns true if the given path has an extension.

filepath:split-all-extensions PATHprocedure

Splits path on the first extension.

filepath:drop-all-extensions PATHprocedure

Removes all extensions from the path.

filepath:take-all-extensions PATHprocedure

Returns all extensions from the path.

Drive procedures

filepath:split-driveprocedure

Splits a path into a Windows drive and a path. When in POSIX mode, / is treated as a drive.

filepath:join-drive DRIVE PATHprocedure

Joins a drive and the rest of the path.

filepath:take-drive PATHprocedure

Returns the drive of a path.

filepath:has-drive? PATHprocedure

Returns whether the given path has a drive.

filepath:drop-drive PATHprocedure

Removes the drive from the given path.

filepath:is-drive? STRINGprocedure

Returns true if the given string is a drive specification.

Operations on a file path

filepath:split-file-name PATHprocedure

Splits a path into directory and file.

filepath:take-file-name PATHprocedure

Returns the filename component of a path.

filepath:replace-file-name PATH FILEprocedure

Replaces the filename component of a path with the given one.

filepath:drop-file-name PATHprocedure

Removes the filename component of a path.

filepath:take-base-name PATHprocedure

Returns the base file name (no extension) of a path.

filepath:replace-base-name PATH BASEprocedure

Replaces the base file name of a path with the given one.

filepath:take-directory PATHprocedure

Returns the directory component of a path.

filepath:replace-directory PATH DIRprocedure

Replaces the directory component of a path with the given one.

filepath:combine PATH1 PATH2procedure

Combines two paths. If the second path is absolute, then it returns the second.

filepath:split-path PATHprocedure

Splits a path by the directory separator.

filepath:join-path LISTprocedure

Joins path elements back together.

filepath:split-directoriesprocedure

As split-path, but does not add trailing separators to each element.

Trailing Separators

filepath:has-trailing-path-separator? PATHprocedure
filepath:add-trailing-path-separator PATHprocedure
filepath:drop-trailing-path-separator PATHprocedure

File Name Normalization and Predicates

filepath:normalise PATHprocedure
filepath:path-equal? PATH1 PATH2procedure
filepath:make-relative ROOT PATHprocedure
filepath:is-relative? PATHprocedure
filepath:is-absolute? PATHprocedure
filepath:is-valid? PATHprocedure
filepath:make-valid PATHprocedure

Requires

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/filepath

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Version History

License

Based on the Haskell FilePath library by Neil Mitchell.

Copyright 2008-2019 Ivan Raikov.

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

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.

Contents »