Eclipse Lisp: Pathnames


This section covers: The printing of pathnames when *print-readable* is true is described in the PRINTING: Readable Pathnames section of "Implementation-Defined ANSI Features". The behavior of the external-format argument to open, compile-file and load is described in the Interaction with Streams section of "Characters in Eclipse".

GENERAL

Hosts

A null or :UNSPECIFIC host component is assumed to refer to the machine on which Eclipse is running. A host matching the string returned by the function machine-instance is also recognized as referring to a pathname on the machine running Eclipse.

Other host component strings are accepted within pathnames (i.e. within pure pathname operations), but at this time, only the local host is recognized for interactions with the file system (eg. actually opening a file).

Versions

Numeric versions are recognized, even when the operating system does not support versioning. Version 1 is the oldest, version 2 the next oldest, and so on. In addition, the following keywords are recognized in pathname components:

A file in the file system with version :UNSPECIFIC is always considered to be a higher version than any numbered version. When creating a :NEWEST file, there are two possible actions, depending on the state of matching files in the file system:

  1. If only numbered versions exist for the file, then the new file has a numeric version one greater than the other files in the system.
  2. If there is an existing unnumbered version of the file, then it is renamed to have a version number one greater than any existing numbered version. The new file that is created will have a version of :UNSPECIFIC.

This allows mnemonic versions such as :NEWEST to work regardless of whether or not files have been set up outside of Eclipse to use version numbers.

N.B.: The concept of version numbers, as defined by Common Lisp, has nothing to do with file-write-date. It is possible to create a file, using Eclipse or some other facility, which has a version number lower than another file, but which has a file-write-date that is greater than the other file.

Truenames

As defined by ANSI, a truename is a canonicalized pathname in which wildcards and mnemonic version numbers have been resolved, logical host translations have been resolved, and, in general, multiple ways of referring to the same file in the file system have been resolved to the most canonical form.

There are two Eclipse-specific aspects of this last issue that are of note:

  1. In some situations, some file systems, such as Unix, allow namestrings that refer to directories to be specified with or without the trailing directory separator (eg. "/dir/subdir" or "/dir/subdir/"). In other words, something that looks like a filename might refer to a file or to a directory.

    In Eclipse, the truename of a directory is always canonicalized such that the namestring prints as a directory (eg. "/dir/subdir/"), and the pathname-name, pathname-type and pathname-version are all :UNSPECIFIC.

  2. Some file systems allow files to be symbolically linked to other files or directories. In general, Eclipse truenames resolve such links to their ultimate file or directory destination. However, directory allows the programmer to specify whether such symbolic links are followed once, completely, or not at all.

Canonicalization of Components

Internally, the strings which form the components of pathnames are cased analogously to the way strings are cased by the reader when creating symbols. Lisp always compares symbols in a case-sensitive way, but canonicalizes the strings during read, based on the value of readtable-case. When readtable-case is :UPCASE, (the default,) all lowercase characters that will form the name of a symbol are converted to the corresponding uppercase character at read time.

Eclipse uses a similar canonicalization when converting namestrings to pathnames. Logical pathname namestrings are canonicalized as though by readtable-case :UPCASE, so logical pathnames are effectively case insensitive and the component strings are always uppercase. Other pathname types might use other case canonicalizations, equivalent to readtable-case :PRESERVE for a case-sensitive system in which namestrings are normally entered in uppercase or :INVERT for a case-sensitive system in which namestrings are normally entered in lowercase.

Some pathname types might support additional canonicalizations. For example, for a host that only supports three letter file types, the version component of "file.lsp" might be canonicalized to "LISP". No such additional canonicalizations are currently defined.

Comparisons of components for pathname-match-p and its callers are case sensitive, but use the canonicalized components.


PHYSICAL PATHNAMES

Eclipse pathnames can internally represent physical pathnames that may not have legal namestrings for the corresponding file system. For example:

:UNSPECIFIC components are ommited from namestrings.

Most Lisp file system operations perform merging, logical-pathname translation, and explicit checking for wild components. The consequences are undefined if the result of this process yields a namestring that is not valid or complete for the corresponding file system. For example, if a directory is explicitly given as :UNSPECIFIC, and thus cannot be merged out by Eclipse, then the operating system might use the "root" directory or supply some default directory that may be different than the current value of *default-pathname-defaults*.

The consequences are undefined for file system interactions if a character that is not an ASCII-char appears in a final pathname namestring.

Eclipse currently recognizes Unix pathnames and Windows pathnames.

Unix Pathnames

The syntax for physical pathnames on Unix hosts matches that of the Unix system. In addition, a host name may be specified with a HOST-NAME: prefix. For example,
   foo:/usr/joe/file.lisp.9
parses as
   #S(PATHNAME :HOST "foo" :DEVICE :UNSPECIFIC 
      :DIRECTORY (:ABSOLUTE "usr" "joe") 
      :NAME "file" :TYPE "lisp" :VERSION 9)
(See Printing, in "Eclipse-Defined ANSI features".)

Namestrings are canonicalized as though by readtable-case :INVERT.

The default device for all Unix pathnames is :UNSPECIFIC.

Windows Pathnames

The syntax for physical pathnames on Windows hosts matches Windows' long pathname syntax. In addition, a host name may be specified with a [HOST-NAME] prefix. For example,
   [foo]d:\usr\joe\file.lisp.9
parses as
   #S(PATHNAME :HOST "FOO" :DEVICE "D"
      :DIRECTORY (:ABSOLUTE "USR" "JOE") 
      :NAME "FILE" :TYPE "LISP" :VERSION 9)
(See Printing, in "Eclipse-Defined ANSI features".)

Namestrings are canonicalized as though by readtable-case :UPCASE.

Both forward slashes '/' and backslashes '\' may be used in Windows namestrings. Pathname namestrings are printed using backslashes, which the Lisp printer escapes by preceding them with an additional backslash:

  (pathname "/foo/bar")
  => #P"\\FOO\\BAR"
  (length (namestring *))
  => 8

The default device is :UNSPECIFIC, which means that the operating system's current default drive is used.


IMPLEMENTATION-DEFINED BEHAVIOR OF ANSI FUNCTIONS

Parse-Namestring

Parse-namestring always parses the namestring using the syntax specified for a particular host's pathname type (eg logical pathname, Unix pathname, etc). The determination of which host syntax to use is computed as follows:
  1. If a non-null host argument is specified in the call to parse-namestring, the syntax for that host is used. If a non-null, but unknown host is specified, an error is signaled.
  2. Otherwise, if namestring has an explicit host consistent with the syntax used by that host, the syntax of that host is used.
  3. Otherwise, the syntax of the default-pathname is used.
Note that regardless of what syntax is used to parse the namestring, a host appearing explicitly in namestring is used as the host of the resulting pathname and need not match the host of the defaults. It does have to match an explicit non-null host argument, however. Also, the default-pathname argument is used only for determining namestring syntax, and is not used for merging.

Pathname-match-p

The following apply to pathname matching:

Translate-pathname, translate-logical-pathname

The rules for pathname-match-p apply to translate-pathname. The portion of source that is copied in the resulting pathname follows the "usual" behavior described in the ANSI standard.

As with pathname-match-p, the components are operated on in :COMMON :CASE, so the :LOCAL :CASE of translated components may change if the pathname host changes after the translation.

Load-logical-pathname-translations

If the host argument to load-logical-pathname-translations is not already defined as a logical-host, then this function attempts to load the file:
  (make-pathname :host "SYS"
		 :directory '(:absolute "SITE")
		 :name host :type "HOST" :version :newest)
The definition of the SYS logical host is defined by Lisp Top-Level features.

Directory

As defined by ANSI, directory always returns truenames.

In Eclipse, directory accepts an additional keyword argument named :LINKS, which specifies whether links should be followed during resolution to truenames.

See the Eclipse Dictionary specification for directory.


[Previous] [Next] [Up] [Documentation Contents] [Eclipse Home Page]