Common Lisp the Language, 2nd Edition
Here is a very simple example of setting up a logical pathname host named FOO.
Suppose that no
translations are necessary to get around file system restrictions, so
all that is necessary is to specify the root of the physical directory
tree that contains the logical file system.
The namestring syntax in the to-wildname is implementation-specific.
(setf (logical-pathname-translations "foo") '(("**;*.*.*" "MY-LISPM:>library>foo>**>")))
The following is a sample use of that logical pathname. All return values are of course implementation-specific; all of the examples in this section are of course meant to be illustrative and not prescriptive.
(translate-logical-pathname "foo:bar;baz;mum.quux.3") => #P"MY-LISPM:>library>foo>bar>baz>mum.quux.3"
Next we have a more complex example, dividing the files among two file servers (U, supporting a UNIX file system, and V, supporting a VAX/VMS file system) and several different directories. This UNIX file system doesn't support :wild-inferiors in the directory, so each directory level must be translated individually. No file name or type translations are required except for .MAIL to .MBX. The namestring syntax used for the to-wildnames is implementation-specific.
(setf (logical-pathname-translations "prog") '(("RELEASED;*.*.*" "U:/sys/bin/my-prog/") ("RELEASED;*;*.*.*" "U:/sys/bin/my-prog/*/") ("EXPERIMENTAL;*.*.*" "U:/usr/Joe/development/prog/") ("EXPERIMENTAL;DOCUMENTATION;*.*.*" "V:SYS$DISK:[JOE.DOC]") ("EXPERIMENTAL;*;*.*.*" "U:/usr/Joe/development/prog/*/") ("MAIL;**;*.MAIL" "V:SYS$DISK:[JOE.MAIL.PROG...]*.MBX") ))
Here are sample uses of logical host PROG. All return values are of course implementation-specific.
(translate-logical-pathname "prog:mail;save;ideas.mail.3") => #P"V:SYS$DISK:[JOE.MAIL.PROG.SAVE]IDEAS.MBX.3" (translate-logical-pathname "prog:experimental;spreadsheet.c") => #P"U:/usr/Joe/development/prog/spreadsheet.c"
Suppose now that we have a program that uses three files logically named MAIN.LISP, AUXILIARY.LISP, and DOCUMENTATION.LISP. The following translations might be provided by a software supplier as examples.
For a UNIX file system with long file names:
(setf (logical-pathname-translations "prog") '(("CODE;*.*.*" "/lib/prog/"))) (translate-logical-pathname "prog:code;documentation.lisp") => #P"/lib/prog/documentation.lisp"
For a UNIX file system with 14-character file names, using .lisp as the type:
(setf (logical-pathname-translations "prog") '(("CODE;DOCUMENTATION.*.*" "/lib/prog/docum.*") ("CODE;*.*.*" "/lib/prog/"))) (translate-logical-pathname "prog:code;documentation.lisp") => #P"/lib/prog/docum.lisp"
For a UNIX file system with 14-character file names, using .l as the type (the second translation shortens the compiled file type to .b):
(setf (logical-pathname-translations "prog") `(("**;*.LISP.*" ,(logical-pathname "PROG:**;*.L.*")) (,(compile-file-pathname (logical-pathname "PROG:**;*.LISP.*")) ,(logical-pathname "PROG:**;*.B.*")) ("CODE;DOCUMENTATION.*.*" "/lib/prog/documentatio.*") ("CODE;*.*.*" "/lib/prog/"))) (translate-logical-pathname "prog:code;documentation.lisp") => #P"/lib/prog/documentatio.l"