The pathname-utils Reference Manual

This is the pathname-utils Reference Manual, version 1.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:31:41 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 pathname-utils

A collection of utilities for pathname manipulation.

Maintainer

Yukari Hafner <>

Author

Yukari Hafner <>

Home Page

https://Shinmera.github.io/pathname-utils/

Source Control

(GIT https://github.com/Shinmera/pathname-utils.git)

Bug Tracker

https://github.com/Shinmera/pathname-utils/issues

License

zlib

Version

1.1.0

Dependency

trivial-features (system).

Source

pathname-utils.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 pathname-utils/pathname-utils.asd

Source

pathname-utils.asd.

Parent Component

pathname-utils (system).

ASDF Systems

pathname-utils.


3.1.2 pathname-utils/package.lisp

Source

pathname-utils.asd.

Parent Component

pathname-utils (system).

Packages

pathname-utils.


3.1.3 pathname-utils/toolkit.lisp

Dependency

package.lisp (file).

Source

pathname-utils.asd.

Parent Component

pathname-utils (system).

Public Interface
Internals

getenv (function).


3.1.4 pathname-utils/documentation.lisp

Dependency

toolkit.lisp (file).

Source

pathname-utils.asd.

Parent Component

pathname-utils (system).

Internals

4 Packages

Packages are listed by definition order.


4.1 pathname-utils

Source

package.lisp.

Nickname

org.shirakumo.pathname-utils

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *wild-component*

The proper value to use for a wild pathname component.

Package

pathname-utils.

Source

toolkit.lisp.

Special Variable: *wild-directory*

A pathname that is wild in its directory spec (can match any directory).

Package

pathname-utils.

Source

toolkit.lisp.

Special Variable: *wild-file*

A pathname that is wild in its file spec (can match any file).

Package

pathname-utils.

Source

toolkit.lisp.

Special Variable: *wild-inferiors*

A pathname that has wild inferiors (can match any number of subdirectories).

Package

pathname-utils.

Source

toolkit.lisp.

Special Variable: *wild-inferiors-component*

The proper value to use for a wild inferiors pathname component.

Package

pathname-utils.

Source

toolkit.lisp.

Special Variable: *wild-path*

A pathname that is wild in both its file and its directory.

Package

pathname-utils.

Source

toolkit.lisp.


5.1.2 Ordinary functions

Function: absolute-p (pathname)

Returns the pathname if it is an absolute pathname.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: clean-directory-spec (dir &key resolve-home)

Removes superfluous components from the directory spec.

Specifically, if the encountered part is UNSPECIFIC or the string ".", it is omitted. If the part is :BACK, the preceding component is omitted if possible. If not possible, an equivalent amount of :UP specs are inserted instead.

If RESOLVE-HOME is T then the :HOME part, if present, is replaced by the actual directory components of USER-HOMEDIR-PATHNAME

Package

pathname-utils.

Source

toolkit.lisp.

Function: components (pathname)

Returns a plist containing all the components making up the given pathname.

The plist contains the following keys:
:namestring
:truename
:host
:device
:name
:type
:version
:directory

If the pathname has no truename, its value in the plist is NIL.

Package

pathname-utils.

Source

toolkit.lisp.

Function: directory-name (pathname)

Returns the name of the topmost directory in the pathname, if any.

The pathname is coerced using TO-DIRECTORY

See TO-DIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: directory-p (pathname)

Returns the pathname if it denotes a directory (not a file).

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: directory-separator (&optional pathname)

Returns the namestring separator between directories as a string.

Package

pathname-utils.

Source

toolkit.lisp.

Function: dos-namestring (pathname &key stream junk-allowed)

Produce a namestring according to DOS rules.

- If the pathname is absolute:
- If the first directory component is :HOME, the (USER-HOMEDIR-PATHNAME) is emitted.
- If the pathname has a device, the device name followed by a colon and a backslash is emitted.
- Otherwise a backslash is emitted.
- For every directory component, the component followed by a backslash is emitted. In the case of :UP or :BACK, they are emitted as two dots.
- The pathname name, if any, is emitted
- The pathname type, if any, is emitted following a dot.

If the pathname contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed. If the error is continued or :JUNK-ALLOWED T is passed, the component or character is ignored. The following characters are illegal:
\ / < > : " | ? * Nul

If STREAM is NIL, the namestring is printed to a string and returned.

See NATIVE-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: downwards (pathname subdir)

Moves the topmost pathname component a level downwards.

Specifically, if we have a file "foo/bar.jpg", and move it downwards by "baz", the resulting pathname will be "foo/baz/bar.jpg". If the pathname is a directory-pathname then the last directory is moved downwards by one.

See SUBDIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: enough-pathname (subpath base)

Like ENOUGH-NAMESTRING but returns an actual pathname.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: file-in (directory file)

Returns a pathname to the given file but in the given directory.

This is useful when carrying over a file to another directory. Essentially this constructs a pathname with the name and type of FILE, but the rest of DIR.

Package

pathname-utils.

Source

toolkit.lisp.

Function: file-name (pathname)

Returns the complete file name as it would be used by the OS, if any.

If the pathname is wild in its name or type component, an error is signalled.

Package

pathname-utils.

Source

toolkit.lisp.

Function: file-p (pathname)

Returns the pathname if it denotes a file (not a directory).

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: file-type (pathname)

Returns the actual file type.

This is different from PATHNAME-TYPE in the following manner:
If PATHNAME-TYPE is specific, but contains a dot, only the part after the last dot is used as it would indicate the actual file-type on any recent system. If PATHNAME-TYPE is unspecific, the PATHNAME-NAME is specific, and it contains a dot in any position but the first, then that last part is used instead. Otherwise NIL is returned.

If the pathname is wild in its type or name component, an error is signalled.

Package

pathname-utils.

Source

toolkit.lisp.

Function: force-directory (pathname)

Forces the pathname into a directory, including its file namestring.

Meaning: #p"a" => #p"a/"

The pathname is first coerced using PATHNAME*

See PATHNAME*
See TO-DIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: logical-p (pathname)

Returns the pathname if it is a logical pathname.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: native-namestring (pathname &key stream junk-allowed)

Produce a namestring appropriate for the current platform.

This avoids pitfalls with printing namestrings with the default common lisp functions, as they may contain unsuitable characters, or syntax not known to other native applications.

If the pathname contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed.

If STREAM is NIL, the namestring is printed to a string and returned.

See PARSE-NATIVE-NAMESTRING
See UNIX-NAMESTRING
See DOS-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: normalize-directory-spec (dir &key resolve-home)

Attempts to normalize the directory specification into one as specified by CLHS.

Also cleans the directory spec.

See CLEAN-DIRECTORY-SPEC.

Package

pathname-utils.

Source

toolkit.lisp.

Function: normalize-pathname (pathname &key resolve-home)

Returns a normalised form of the given pathname.

More specifically, the given object is ensured to be a pathname using CL:PATHNAME, then turned into a new pathname with the following properties: an unspecific component is turned into NIL and the directory component is normalised through NORMALIZE-DIRECTORY-SPEC.

See UNSPECIFIC-P
See NORMALIZE-DIRECTORY-SPEC

Package

pathname-utils.

Source

toolkit.lisp.

Function: parent (pathname)

Returns the parent of the pathname.

If the pathname is a directory-pathname, it returns a pathname that points to the parent thereof, if possible. Specifically, if the directory is relative and empty, :up is inserted. If it is absolute and empty, the same pathname is returned. If it is not empty, then the last component of the directory is removed. If the pathname is a file pathname, this is equivalent to TO-DIRECTORY.

The pathname is coerced using PATHNAME*.

If you need to preserve the pathname’s file component, consider using UPWARDS instead.

See PATHNAME*
See TO-DIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: parse-dos-namestring (namestring &key as junk-allowed)

Parse a namestring according to DOS rules.

Specifically:

- A path starting with a character followed by a colon is an absolute path.
- Any subsequent slash or backslash is used as a directory separator. - A path starting with a directory component that starts and ends with a percentage is denoting a environment-variable-relative pathname and is parsed by merging the rest of the parsed pathname with the pathname resulting from parsing the environment variable of the indicated name. If the variable is empty or does not exist, it is ignored.
- A directory component that is empty is ignored.
- A directory component that is a single dot is ignored.
- A directory component that is two dots is converted to :BACK.
- If the namestring is a file namestring:
- If the file namestring starts with a dot, the entire file namestring is used as the pathname’s name, including the dot. - If the file namestring contains one or more dots not in the leading position, the part after the last dot is used as the pathname type, and the rest as the name.

You may also pass :AS :DIRECTORY to force the namestring to be turned into a directory-pathname even if it does not end in a directory separator.

If the namestring contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed. If the error is continued or :JUNK-ALLOWED T is passed, the component or character is ignored. The following characters are illegal:
< > : " | ? * Nul

See PARSE-NATIVE-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: parse-native-namestring (namestring &key as junk-allowed)

Parse a namestring appropriate for the current platform.

This avoids pitfalls with parsing namestrings with the default common lisp functions where possible, as they treat certain characters specially to allow for wild pathnames.

You may also pass :AS :DIRECTORY to force the namestring to be turned into a directory-pathname even if it does not end in a directory separator.

If the namestring contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed.

See NATIVE-NAMESTRING
See PARSE-UNIX-NAMESTRING
See PARSE-DOS-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: parse-unix-namestring (namestring &key as junk-allowed)

Parse a namestring according to Unix rules.

Specifically:

- A path with a leading slash is an absolute path.
- Any subsequent slash is used as a directory separator.
- A path with a tilde as the first directory component points to the home directory.
- A directory component that is empty is ignored.
- A directory component that is a single dot is ignored.
- A directory component that is two dots is converted to :BACK.
- If the namestring is a file namestring:
- If the file namestring starts with a dot, the entire file namestring is used as the pathname’s name, including the dot. - If the file namestring contains one or more dots not in the leading position, the part after the last dot is used as the pathname type, and the rest as the name.

You may also pass :AS :DIRECTORY to force the namestring to be turned into a directory-pathname even if it does not end in a directory separator.

If the namestring contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed. If the error is continued or :JUNK-ALLOWED T is passed, the component or character is ignored. The following characters are illegal:
Nul

See PARSE-NATIVE-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: pathname* (pathname)

Ensures that the argument is a pathname.

If a pathname is passed, it is returned verbatim.
If it is anything else, the value is coerced to a pathname using NORMALIZE-PATHNAME.

See NORMALIZE-PATHNAME

Package

pathname-utils.

Source

toolkit.lisp.

Function: pathname-equal (a b)

Returns T if the two pathnames denote the same file.

Note that this comparison has to access the file system and might therefore be costly.

First the two pathnames are turned into truenames using TRUENAME and then compared using PATHNAME=. This should result in a comparison that returns true in any situation where the two pathnames really do refer to the same file, but might not look the same due to symbolic links or similar effects in the file system.

See CL:TRUENAME
See PATHNAME=

Package

pathname-utils.

Source

toolkit.lisp.

Function: pathname= (a b &key ignore-version)

Returns T if the two pathnames are the same.

Note that this comparison is purely based on the pathnames itself and does not check whether the two might resolve to the same file on the system.

Relative pathnames are turned into absolute ones by merging them with *default-pathname-defaults* before being compared.

Each component of the pathnames are compared using EQUAL, but treating parts that are UNSPECIFIC-P as the same, regardless of the way in which they might be unspecific.

If IGNORE-VERSION is non-NIL (the default), then the version component of the pathnames is not compared. This is useful, as it can be different for pathnames that appear to be the same on some implementations.

See UNSPECIFIC-P

Package

pathname-utils.

Source

toolkit.lisp.

Function: physical-p (pathname)

Returns the pathname if it is a physical pathname.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: pop-directory (pathname)

Pops the last component off the pathname-directory part.

The pathname is coerced using PATHNAME*.
Note that this will probably not behave as expected for pathnames containing :back and :up. For the "intuitive" behaviour to ascend pathnames, see PARENT or UPWARDS.

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: relative-p (pathname)

Returns the pathname if it is a relative pathname.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: relative-pathname (from to)

Computes a relative pathname from one place to another.

The pathnames are first turned into absolute ones by MERGE-PATHNAMES. Then, the common directory components are eliminated, leftover directory components on the from path are converted into :up, and finally the remaining components of the to path are appended, producing the final directory component. The name, type, and version are taken from the to pathname.

If the two pathnames differ in device or host, an error is signalled instead.

The pathnames are coerced using NORMALIZE-PATHNAME after the merge.

See NORMALIZE-PATHNAME

Package

pathname-utils.

Source

toolkit.lisp.

Function: root-p (pathname)

Returns the pathname if it denotes an absolute root directory.

The pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: subdirectory (pathname &rest subdirs)

Returns a directory-pathname with the given subdirectories appended.

For example, appending "bar" and "baz" to "foo/" will
result in "foo/bar/baz/".

The PATHNAME is coerced using TO-DIRECTORY. For any of the subdirs, if it is a pathname, stream, or keyword, it is coerced to a pathname using TO-DIRECTORY. If it is a string, it is coerced using TO-DIRECTORY but with a trailing slash appended.

If you need to preserve the pathname’s file component, consider using DOWNWARDS instead.

See TO-DIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: subpath-p (subpath base &optional root)

Returns true if SUBPATH denotes a path on a lower level than BASE.

A pathname is considered a subpath of a base pathname if all of the following are true:
- Their hosts match
- Their devices match
- The base’s name is null or their names match
- The base’s type is null or their types match
- The directory component of the subpath denotes a subdirectory of the directory component of the base.

If the subpath or base are relative pathnames, they are made absolute by merging them with the root pathname. If the root pathname is relative, an error is signalled.

The actually returned value is the coerced value of SUBPATH by NORMALIZE-PATHNAME.

See NORMALIZE-PATHNAME

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-absolute (pathname)

Turns the pathname into an absolute pathname.

The given pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-directory (pathname)

Turns the pathname into a pathname-directory if it is not already one.

If the argument is :UP or :BACK, it is turned into a relative pathname with the argument as its only pathname-directory-component. If the argument is :HOME, it is turned into an absolute pathname pointing to the home directory.
Otherwise the pathname is coerced using PATHNAME*

See PATHNAME*
See FORCE-DIRECTORY

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-file (pathname)

Turns the pathname into a file pathname.

This means stripping the device, host, and directory components of the pathname. The given pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-physical (pathname)

Turns the pathname into a physical one if it is not already one.

The pathname is coerced using PATHNAME*

See LOGICAL-P
See CL:TRANSLATE-LOGICAL-PATHNAME
See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-relative (pathname)

Turns the pathname into a relative pathname.

The given pathname is coerced using PATHNAME*

See PATHNAME*

Package

pathname-utils.

Source

toolkit.lisp.

Function: to-root (pathname)

Returns the absolute root of the pathname.

Package

pathname-utils.

Source

toolkit.lisp.

Function: unix-namestring (pathname &key stream junk-allowed)

Produce a namestring according to Unix rules.

- If the pathname is absolute:
- If the first directory component is :HOME, ~/ is emitted
- Otherwise / is emitted
- For every directory component, the component followed by a slash is emitted. In the case of :UP or :BACK, they are emitted as two dots. - The pathname name, if any, is emitted
- The pathname type, if any, is emitted following a dot.

If the pathname contains illegal characters or components, a continuable error is signalled unless :JUNK-ALLOWED T is passed. If the error is continued or :JUNK-ALLOWED T is passed, the component or character is ignored. The following characters are illegal:
/ Nul

If STREAM is NIL, the namestring is printed to a string and returned.

See NATIVE-NAMESTRING

Package

pathname-utils.

Source

toolkit.lisp.

Function: unspecific-p (component)

Returns true if the given component is unspecific.

This includes :UNSPECIFIC, NIL, and the empty string.

Package

pathname-utils.

Source

toolkit.lisp.

Function: upwards (pathname)

Moves the topmost pathname component a level upwards.

Specifically, if we have a file "foo/bar/baz.jpg", and move it upwards by one, the resulting pathname will be "foo/baz.jpg". If the pathname is a directory-pathname then the last directory is moved upwards by one.

See PARENT

Package

pathname-utils.

Source

toolkit.lisp.


5.2 Internals


5.2.1 Macros

Macro: setdocs (&body pairs)

Easily set the documentation.

Package

pathname-utils.

Source

documentation.lisp.


5.2.2 Ordinary functions

Function: checkdocs (&optional package)

Check that all functions, classes, and variables have docstrings.

Package

pathname-utils.

Source

documentation.lisp.

Function: getenv (x)
Package

pathname-utils.

Source

toolkit.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   C   D   E   F   G   L   M   N   P   R   S   T   U  
Index Entry  Section

A
absolute-p: Public ordinary functions

C
checkdocs: Private ordinary functions
clean-directory-spec: Public ordinary functions
components: Public ordinary functions

D
directory-name: Public ordinary functions
directory-p: Public ordinary functions
directory-separator: Public ordinary functions
dos-namestring: Public ordinary functions
downwards: Public ordinary functions

E
enough-pathname: Public ordinary functions

F
file-in: Public ordinary functions
file-name: Public ordinary functions
file-p: Public ordinary functions
file-type: Public ordinary functions
force-directory: Public ordinary functions
Function, absolute-p: Public ordinary functions
Function, checkdocs: Private ordinary functions
Function, clean-directory-spec: Public ordinary functions
Function, components: Public ordinary functions
Function, directory-name: Public ordinary functions
Function, directory-p: Public ordinary functions
Function, directory-separator: Public ordinary functions
Function, dos-namestring: Public ordinary functions
Function, downwards: Public ordinary functions
Function, enough-pathname: Public ordinary functions
Function, file-in: Public ordinary functions
Function, file-name: Public ordinary functions
Function, file-p: Public ordinary functions
Function, file-type: Public ordinary functions
Function, force-directory: Public ordinary functions
Function, getenv: Private ordinary functions
Function, logical-p: Public ordinary functions
Function, native-namestring: Public ordinary functions
Function, normalize-directory-spec: Public ordinary functions
Function, normalize-pathname: Public ordinary functions
Function, parent: Public ordinary functions
Function, parse-dos-namestring: Public ordinary functions
Function, parse-native-namestring: Public ordinary functions
Function, parse-unix-namestring: Public ordinary functions
Function, pathname*: Public ordinary functions
Function, pathname-equal: Public ordinary functions
Function, pathname=: Public ordinary functions
Function, physical-p: Public ordinary functions
Function, pop-directory: Public ordinary functions
Function, relative-p: Public ordinary functions
Function, relative-pathname: Public ordinary functions
Function, root-p: Public ordinary functions
Function, subdirectory: Public ordinary functions
Function, subpath-p: Public ordinary functions
Function, to-absolute: Public ordinary functions
Function, to-directory: Public ordinary functions
Function, to-file: Public ordinary functions
Function, to-physical: Public ordinary functions
Function, to-relative: Public ordinary functions
Function, to-root: Public ordinary functions
Function, unix-namestring: Public ordinary functions
Function, unspecific-p: Public ordinary functions
Function, upwards: Public ordinary functions

G
getenv: Private ordinary functions

L
logical-p: Public ordinary functions

M
Macro, setdocs: Private macros

N
native-namestring: Public ordinary functions
normalize-directory-spec: Public ordinary functions
normalize-pathname: Public ordinary functions

P
parent: Public ordinary functions
parse-dos-namestring: Public ordinary functions
parse-native-namestring: Public ordinary functions
parse-unix-namestring: Public ordinary functions
pathname*: Public ordinary functions
pathname-equal: Public ordinary functions
pathname=: Public ordinary functions
physical-p: Public ordinary functions
pop-directory: Public ordinary functions

R
relative-p: Public ordinary functions
relative-pathname: Public ordinary functions
root-p: Public ordinary functions

S
setdocs: Private macros
subdirectory: Public ordinary functions
subpath-p: Public ordinary functions

T
to-absolute: Public ordinary functions
to-directory: Public ordinary functions
to-file: Public ordinary functions
to-physical: Public ordinary functions
to-relative: Public ordinary functions
to-root: Public ordinary functions

U
unix-namestring: Public ordinary functions
unspecific-p: Public ordinary functions
upwards: Public ordinary functions