Note: This is taken from the Chicken Wiki, where a more recent version could be available.

FSPath - CommonLISP style Namestring and Pathname Object

FSPath is an extension of unit utils pathname concept.

The extended pathname is referred to as a namestring.

The CommonLISP pathname object analog is the fs:pathname record object.

Namestring

Four styles of namestring are supported:

UNC
Universal Naming Convention, platform specific
FIL
Filename, platform specific
URI ; Universal Resource Identifier
FSS
Filesystem Specific (Unimplemented)

Record fs:pathname

These namestring forms are mapped into fs:pathname components:

host
host descriptor - hostname, IP address, domain name
origin
drive, port, volume, device, logical name, environment variable
directory
list of fs:filename representing directory components
filename
fs:fIlename

The fs:pathname record is to be a logical pathname, portable across platforms.

Any missing component is represented by #f.

A SRFI-10 reader and printer are supplied.

Record fs:filename

These namestring forms are mapped into fs:filename components:

base
string or symbol
extensions
list-of string or symbol
version
positive integer, symbol oldest, or symbol newest

The fs:filename record is to be a logical filename, portable across platforms.

Any missing component is represented by #f.

A SRFI-10 reader and printer are supplied.

UNC

Windows:

\\<host>\<origin>\<directory>\<name>.<extension>[.<extension> ...]~<version>~

\\?\UNC\<host>\<origin>\<directory>\<name>.<extension>[.<extension> ...].~<version>~

Unix:

//<host>/<origin>/<directory>/<name>.<extension>[.<extension> ...].~<version>~

<host>:/<origin>/<directory>/<name>.<extension>[.<extension> ...].~<version>~

FIL

Windows:

<origin>:\<directory>\<name>.<extension>[.<extension> ...]~<version>~

\\?\<origin>:\<directory>\<name>.<extension>[.<extension> ...]~<version>~

Unix:

/<directory>/<base>.<extension>[.<extension> ...]~<version>~

FSS

This form is filesystem specific.

<specific>

Parameters

fs:default-unc-format

[procedure] (fs:default-unc-format [FORM])

Gets or sets the behavior for converting a unc form to a namestring. Accepatble FORM is one of colon, slash, or uri.

fs:allow-empty-name

[procedure] (fs:allow-empty-name [FLAG])

Gets or sets the behavior for an empty namestring, where #f means empty strings are ignored.

Pathname Procedures

fs:pathname?

[procedure] (fs:pathname? OBJECT)

Is the OBJECT an fs:pathname object?

fs:make-pathname

[procedure] (fs:make-pathname FILENAME)
[procedure] (fs:make-pathname [DIRECTORY] FILENAME)
[procedure] (fs:make-pathname [BASE] DIRECTORY FILENAME)
[procedure] (fs:make-pathname [HOST] BASE DIRECTORY FILENAME)

Returns a new fs:pathname object. Default for all parameters is #f.

When directory is a string it is split into a list.

fs:pathname-host

[procedure] (fs:pathname-host PATHNAME)

Gets the host component of the PATHNAME object.

fs:pathname-origin

[procedure] (fs:pathname-origin PATHNAME)

Gets the origin component of the PATHNAME object.

fs:pathname-directory

[procedure] (fs:pathname-directory PATHNAME)

Gets the directory component of the PATHNAME object.

fs:pathname-filename

[procedure] (fs:pathname-filename PATHNAME)

Gets the filename component of the PATHNAME object.

→fs:pathname

[procedure] (->fs:pathname OBJECT)

Returns a new fs:pathname object from the OBJECT.

fs:pathname-namestring

[procedure] (fs:pathname-namestring PATHNAME)

Returns a new NAMESTRING from the PATHNAME object.

fs:pathname-components

[procedure] (fs:pathname-components PATHNAME)

Returns a list of the PATHNAME fields.

fs:pathname+filename-components

[procedure] (fs:pathname+filename-components PATHNAME)

Returns a list of the PATHNAME and the PATHNAME-FILENAME fields.

fs:make-relative-pathname

[procedure] (fs:make-relative-pathname DIRECTORY FILENAME)

Returns fs:pathname.

fs:namestring→pathname

[procedure] (fs:namestring->pathname NAMESTRING)

Returns fs:pathname.

uri→fs:pathname

[procedure] (uri->fs:pathname URI)

Returns fs:pathname.

fs:pathname-default

[procedure] (fs:pathname-default PATHNAME [FILENAME])
[procedure] (fs:pathname-default PATHNAME [DIRECTORY] FILENAME)
[procedure] (fs:pathname-default PATHNAME [ORIGIN] DIRECTORY FILENAME)
[procedure] (fs:pathname-default PATHNAME [HOST] ORIGIN DIRECTORY FILENAME)

Returns fs:pathname.

fs:pathname/host

[procedure] (fs:pathname/host PATHNAME HOST)

Returns fs:pathname.

fs:pathname/origin

[procedure] (fs:pathname/origin PATHNAME ORIGIN)

Returns fs:pathname.

fs:pathname/directory

[procedure] (fs:pathname/directory PATHNAME DIRECTORY)

Returns fs:pathname.

fs:pathname/filename

[procedure] (fs:pathname/filename PATHNAME FILENAME)

Returns fs:pathname.

fs:pathname/base

[procedure] (fs:pathname/base PATHNAME BASE)

Returns fs:pathname.

fs:pathname/extensions

[procedure] (fs:pathname/extensions PATHNAME EXTENSIONS)

Returns fs:pathname.

fs:pathname/version

[procedure] (fs:pathname/version PATHNAME VERSION)

Returns fs:pathname.

fs:pathname=?

[procedure] (fs:pathname=? PATHNAME ...)

Returns boolean.

fs:pathname-eqv?

[procedure] (fs:pathname-eqv? PATHNAME-A PATHNAME-B)

Returns boolean.

fs:filename-pathname?

[procedure] (fs:filename-pathname? PATHNAME)

Returns boolean.

fs:filename-pathname

[procedure] (fs:filename-pathname PATHNAME)

Returns fs:pathname.

fs:directory-pathname?

[procedure] (fs:directory-pathname? PATHNAME)

Returns boolean.

fs:directory-pathname

[procedure] (fs:directory-pathname PATHNAME)

Returns fs:pathname.

fs:directory-namestring

[procedure] (fs:directory-namestring PATHNAME)

Returns string.

fs:host-namestring

[procedure] (fs:host-namestring PATHNAME)

Returns string.

fs:pathname-namelist

[procedure] (fs:pathname-namelist PATHNAME)

Returns list.

fs:pathname→uri

[procedure] (fs:pathname->uri PATHNAME)

Returns uri.

(fs:merge-pathnames PATHNAME [DEFAULT-PATHNAME])

fs:expand-pathname

[procedure] (fs:expand-pathname PATHNAME)

Returns fs:pathname.

fs:pathname-container

[procedure] (fs:pathname-container PATHNAME)

Returns fs:pathname.

fs:pathname-parent-directory

[procedure] (fs:pathname-parent-directory PATHNAME)

Returns fs:pathname.

fs:enough-pathname

[procedure] (fs:enough-pathname PATHNAME [DEFAULT-PATHNAME])

Returns fs:pathname.

fs:enough-namestring

[procedure] (fs:enough-namestring PATHNAME [DEFAULT-PATHNAME])

Returns string.

fs:pathname-complete?

[procedure] (fs:pathname-complete? PATHNAME)

Returns boolean.

→fs:namestring

[procedure] (->fs:namestring OBJECT)

Returns string.

Filename Procedures

fs:filename?

[procedure] (fs:filename? OBJECT)

Is the OBJECT an fs:filename object?

fs:make-filename

[procedure] (fs:make-filename [BASE [EXTENSION [GENERATION]]])

Returns a new fs:filename object. Default for all parameters is #f.

fs:filename-base

[procedure] (fs:filename-base FILENAME)

Gets the base component of the FILENAME object.

fs:filename-extensions

[procedure] (fs:filename-extensions FILENAME)

Gets the extensions component of the FILENAME object.

fs:filename-version

[procedure] (fs:filename-version FILENAME)

Gets the version component of the FILENAME object.

→fs:filename

[procedure] (->fs:filename OBJECT)

Returns a new fs:filename object from the OBJECT.

fs:filename-namestring

[procedure] (fs:filename-namestring FILENAME)

Returns a new NAMESTRING from the FILENAME object.

fs:filename-components

[procedure] (fs:filename-components FILENAME)

Returns a list of the FILENAME fields.

fs:namestring→filename

[procedure] (fs:namestring->filename NAMESTRING)

Returns fs:filename.

fs:filename-namestring

[procedure] (fs:filename-namestring OBJECT)

Returns string.

fs:filename-default

[procedure] (fs:filename-default FILENAME [BASE [EXTENSIONS [VERSION]]])

Returns fs:filename.

fs:filename/base

[procedure] (fs:filename/base FILENAME BASE)

Returns fs:filename.

fs:filename/extensions

[procedure] (fs:filename/extensions FILENAME EXTENSIONS)

Returns fs:filename.

fs:filename/version

[procedure] (fs:filename/version FILENAME VERSION)

Returns fs:filename.

fs:filename=?

[procedure] (fs:filename=? FILENAME ...)

Returns boolean.

fs:filename-base?

[procedure] (fs:filename-base? OBJECT)

Returns boolean.

fs:filename-extensions?

[procedure] (fs:filename-extensions? OBJECT)

Returns boolean.

fs:filename-extension

[procedure] (fs:filename-extension FILENAME)

Returns (or symbol string #f).

fs:filename-version?

[procedure] (fs:filename-version? OBJECT)

Returns boolean.

fs:filename-complete?

[procedure] (fs:filename-complete? FILENAME)

Returns boolean.

fs:enough-filename

[procedure] (fs:enough-filename FILENAME [DEFAULT-FILENAME])

Returns fs:filename.

fs:merge-filenames

[procedure] (fs:merge-filenames FILENAME DEFAULT-FILENAME)

Returns fs:filename.

fs:filename-namelist

[procedure] (fs:filename-namelist FILENAME [FLATTEN?])

Returns list.

Primitive Procedures

fs$make-filename

[procedure] (fs$make-filename BASE EXTENSIONS VERSION)

Returns fs:filename.

fs$make-filename/components

[procedure] (fs$make-filename/components COMPONENTS CALLER)

Returns fs:filename.

fs$filename-base-set!

[procedure] (fs$filename-base-set! FILENAME BASE)

Returns unspecified.

fs$filename-extensions-set!

[procedure] (fs$filename-extensions-set! FILENAME EXTENSIONS)

Returns unspecified.

fs$filename-version-set!

[procedure] (fs$filename-version-set! FILENAME VERSION)

Returns unspecified.

fs$make-pathname

[procedure] (fs$make-pathname HOST ORIGIN DIRECTORY FILENAME)

Returns fs:pathname.

fs$make-pathname/components

[procedure] (fs$make-pathname/components COMPONENTS CALLER)

Returns fs:pathname.

fs$pathname-host-set!

[procedure] (fs$pathname-host-set! PATHNAME HOST)

Returns unspecified.

fs$pathname-origin-set!

[procedure] (fs$pathname-origin-set! PATHNAME ORIGIN)

Returns unspecified.

fs$pathname-directory-set!

[procedure] (fs$pathname-directory-set! PATHNAME DIRECTORY)

Returns unspecified.

fs$pathname-filename-set!

[procedure] (fs$pathname-filename-set! PATHNAME FILENAME)

Returns unspecified.

Usage

(require-extension fspath)

Requirements

uri

miscmacros

Authors

Kon Lovett

License

Copyright © 2007, 2008 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version History

0.2
Incompatible release with much more functionality
0.1
Initial release

Bugs

Probably a number since the test suite is very incomplete.