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

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 CL pathname object analog is the fspath record object.

Namestring

Four styles of namestring are supported:

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

FSPath Record

These namestring forms are mapped into fspath components:

protocol
URI scheme, Filesystem type
host
Hostname, IP address, Domain name
device
Drive, Port, Volume, Device
directory
Directory, split into a list by directory separator
file
Basename
type
Extension
version
Version, usually a number (Faked for Unix and Windows)

The fspath record is to be a logical pathname, portable across platforms. A fspath created on Windows will be converted to the corresponding namestring on Unix.

Any missing component is represented by #f.

A SRFI-10 reader and printer are supplied.

URI

This form is the same across platforms. This is not a "real" URI, it is unencoded.

<protocol>://<host>:<device>/<directory>/<file>.<type>;<version>

UNC

Windows:

\\<host>\<device>\<directory>\<file>.<type>;<version>

\\?\UNC\<host>\<device>\<directory>\<file>.<type>;<version>

Unix:

//<host>/<device>/<directory>/<file>.<type>;<version>

<host>:/<device>/<directory>/<file>.<type>;<version>

FIL

Windows:

<device>:\<directory>\<file>.<type>;<version>

\\?\<device>:\<directory>\<file>.<type>;<version>

Unix:

/<directory>/<file>.<type>;<version>

FSS

This form is filesystem specific.

<specific>

Procedures

fspath?

[procedure] (fspath? OBJECT)

Is the OBJECT an fspath object?

make-fspath

[procedure] (make-fspath [#:protocol] [#:host] [#:device] [#:directory] [#:file] [#:type] [#:version])

Returns a new fspath object. Default for all keyword parameters is #f.

When protocol is specified then a URI is assumed, unless filesystem specific. When directory is a string it is split into a list.

Windows:

#:wide? specifies if the wide-character prefix '\\?\' is to be used. While the prefix is recognized there is currently no support for the Windows "wide" API.

Unix:

#:unc? specifies if the unc form is to be used; '//<host>' & not '<host>:'.

namestring->fspath

[procedure] (namestring->fspath NAMESTRING)

Returns a new fspath object from the NAMESTRING.

fspath->namestring

[procedure] (fspath->namestring FSPATH)

Returns a new NAMESTRING from the FSPATH object.

fspath-protocol

fspath-host

fspath-device

fspath-directory

fspath-file

fspath-type

fspath-version

[procedure] (fspath-* FSPATH)

Gets the specified component of the FSPATH object.

fspath-protocol-set!

fspath-host-set!

fspath-device-set!

fspath-directory-set!

fspath-file-set!

fspath-type-set!

fspath-version-set!

[procedure] (fspath-*-set! FSPATH VALUE)

Sets the specified component of the FSPATH object to VALUE.

fspath-class-name

[procedure] (fspath-class-name FSPATH)

Returns the kind of FSPATH. Currently one of uri, windows, or unix.

fspath-wide?

fspath-wide-set!

[procedure] (fspath-wide? FSPATH)
[procedure] (fspath-wide-set! FSPATH FLAG)

Windows specific.

fspath-unc?

fspath-unc-set!

[procedure] (fspath-unc? FSPATH)
[procedure] (fspath-unc-set! FSPATH FLAG)

Unix specific.

Usage

(require-extension fspath)

Requirements

uri

Authors

Kon Lovett

License

Copyright (c) 2007 Kon Lovett

Open Source

Version History

0.1
Initial release

Bugs