| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
|
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>logical-pathname-translations (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="logical-pathname-translations (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="logical-pathname-translations (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="Filenames-Dictionary.html" rel="up" title="Filenames Dictionary"> |
| 15 |
<link href="logical_002dpathname.html" rel="next" title="logical-pathname"> |
| 16 |
<link href="load_002dlogical_002dpathname_002dtranslations.html" rel="prev" title="load-logical-pathname-translations"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="logical_002dpathname_002dtranslations"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Next: <a href="logical_002dpathname.html" accesskey="n" rel="next">logical-pathname</a>, Previous: <a href="load_002dlogical_002dpathname_002dtranslations.html" accesskey="p" rel="prev">load-logical-pathname-translations</a>, Up: <a href="Filenames-Dictionary.html" accesskey="u" rel="up">Filenames Dictionary</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="logical_002dpathname_002dtranslations-_005bAccessor_005d"></span><h4 class="subsection">19.4.8 logical-pathname-translations [Accessor]</h4> |
| 46 |
|
| 47 |
<p><code>logical-pathname-translations</code> <i>host</i> ⇒ <i>translations</i> |
| 48 |
</p> |
| 49 |
<p>(setf (<code> logical-pathname-translations</code> <i>host</i>) new-translations)<br> |
| 50 |
</p> |
| 51 |
<span id="Arguments-and-Values_003a_003a-394"></span><h4 class="subsubheading">Arguments and Values::</h4> |
| 52 |
|
| 53 |
<p><i>host</i>–a <i>logical host designator</i>. |
| 54 |
</p> |
| 55 |
<p><i>translations</i>, <i>new-translations</i>—a <i>list</i>. |
| 56 |
</p> |
| 57 |
<span id="Description_003a_003a-512"></span><h4 class="subsubheading">Description::</h4> |
| 58 |
|
| 59 |
<p>Returns the host’s <i>list</i> of translations. |
| 60 |
Each translation is a <i>list</i> of at least two elements: |
| 61 |
<i>from-wildcard</i> and <i>to-wildcard</i>. Any |
| 62 |
additional elements are <i>implementation-defined</i>. |
| 63 |
<i>From-wildcard</i> is a |
| 64 |
<i>logical pathname</i> whose host is <i>host</i>. |
| 65 |
<i>To-wildcard</i> is a <i>pathname</i>. |
| 66 |
</p> |
| 67 |
<p>[Reviewer Note by Laddaga: Can this be a logical pathname?] |
| 68 |
</p> |
| 69 |
<p><tt>(setf (logical-pathname-translations <i>host</i>) <i>translations</i>)</tt> sets a |
| 70 |
<i>logical pathname</i> host’s |
| 71 |
<i>list</i> of <i>translations</i>. If <i>host</i> |
| 72 |
is a <i>string</i> that has |
| 73 |
not been previously used as |
| 74 |
a <i>logical pathname</i> host, a new |
| 75 |
<i>logical pathname</i> host is defined; |
| 76 |
otherwise an existing host’s translations are |
| 77 |
replaced. <i>logical pathname</i> host names are compared with <b>string-equal</b>. |
| 78 |
</p> |
| 79 |
<p>When setting the translations list, each <i>from-wildcard</i> |
| 80 |
can be a <i>logical pathname</i> whose |
| 81 |
host is <i>host</i> or a <i>logical pathname</i> namestring |
| 82 |
parseable by <tt>(parse-namestring <i>string</i> <i>host</i>)</tt>, |
| 83 |
where <i>host</i> |
| 84 |
represents the appropriate <i>object</i> as defined |
| 85 |
by <b>parse-namestring</b>. Each |
| 86 |
<i>to-wildcard</i> can be anything coercible to a |
| 87 |
<i>pathname</i> by |
| 88 |
<tt>(pathname <i>to-wildcard</i>)</tt>. |
| 89 |
If <i>to-wildcard</i> coerces to a <i>logical pathname</i>, |
| 90 |
<b>translate-logical-pathname</b> |
| 91 |
will perform repeated translation steps when |
| 92 |
it uses it. |
| 93 |
</p> |
| 94 |
<p><i>host</i> is either the host component of a |
| 95 |
<i>logical pathname</i> or a |
| 96 |
<i>string</i> that has been defined |
| 97 |
as a <i>logical pathname</i> host name by <b>setf</b> of |
| 98 |
<b>logical-pathname-translations</b>. |
| 99 |
</p> |
| 100 |
<span id="Examples_003a_003a-374"></span><h4 class="subsubheading">Examples::</h4> |
| 101 |
|
| 102 |
<p>[Reviewer Note by Laddaga: Shouldn’t there be some <tt>*.*</tt>’s in the list |
| 103 |
of translations for <tt>PROG</tt> below?] |
| 104 |
</p> |
| 105 |
<div class="example"> |
| 106 |
<pre class="example"> ;;;A very simple example of setting up a logical pathname host. No |
| 107 |
;;;translations are necessary to get around file system restrictions, so |
| 108 |
;;;all that is necessary is to specify the root of the physical directory |
| 109 |
;;;tree that contains the logical file system. |
| 110 |
;;;The namestring syntax on the right-hand side is implementation-dependent. |
| 111 |
(setf (logical-pathname-translations "foo") |
| 112 |
'(("**;*.*.*" "MY-LISPM:>library>foo>**>"))) |
| 113 |
|
| 114 |
;;;Sample use of that logical pathname. The return value |
| 115 |
;;;is implementation-dependent. |
| 116 |
(translate-logical-pathname "foo:bar;baz;mum.quux.3") |
| 117 |
⇒ #P"MY-LISPM:>library>foo>bar>baz>mum.quux.3" |
| 118 |
|
| 119 |
;;;A more complex example, dividing the files among two file servers |
| 120 |
;;;and several different directories. This Unix doesn't support |
| 121 |
;;;:WILD-INFERIORS in the directory, so each directory level must |
| 122 |
;;;be translated individually. No file name or type translations |
| 123 |
;;;are required except for .MAIL to .MBX. |
| 124 |
;;;The namestring syntax on the right-hand side is implementation-dependent. |
| 125 |
(setf (logical-pathname-translations "prog") |
| 126 |
'(("RELEASED;*.*.*" "MY-UNIX:/sys/bin/my-prog/") |
| 127 |
("RELEASED;*;*.*.*" "MY-UNIX:/sys/bin/my-prog/*/") |
| 128 |
("EXPERIMENTAL;*.*.*" "MY-UNIX:/usr/Joe/development/prog/") |
| 129 |
("EXPERIMENTAL;DOCUMENTATION;*.*.*" |
| 130 |
"MY-VAX:SYS$DISK:[JOE.DOC]") |
| 131 |
("EXPERIMENTAL;*;*.*.*" "MY-UNIX:/usr/Joe/development/prog/*/") |
| 132 |
("MAIL;**;*.MAIL" "MY-VAX:SYS$DISK:[JOE.MAIL.PROG...]*.MBX"))) |
| 133 |
|
| 134 |
;;;Sample use of that logical pathname. The return value |
| 135 |
;;;is implementation-dependent. |
| 136 |
(translate-logical-pathname "prog:mail;save;ideas.mail.3") |
| 137 |
⇒ #P"MY-VAX:SYS$DISK:[JOE.MAIL.PROG.SAVE]IDEAS.MBX.3" |
| 138 |
|
| 139 |
;;;Example translations for a program that uses three files main.lisp, |
| 140 |
;;;auxiliary.lisp, and documentation.lisp. These translations might be |
| 141 |
;;;supplied by a software supplier as examples. |
| 142 |
|
| 143 |
;;;For Unix with long file names |
| 144 |
(setf (logical-pathname-translations "prog") |
| 145 |
'(("CODE;*.*.*" "/lib/prog/"))) |
| 146 |
|
| 147 |
;;;Sample use of that logical pathname. The return value |
| 148 |
;;;is implementation-dependent. |
| 149 |
(translate-logical-pathname "prog:code;documentation.lisp") |
| 150 |
⇒ #P"/lib/prog/documentation.lisp" |
| 151 |
|
| 152 |
;;;For Unix with 14-character file names, using .lisp as the type |
| 153 |
(setf (logical-pathname-translations "prog") |
| 154 |
'(("CODE;DOCUMENTATION.*.*" "/lib/prog/docum.*") |
| 155 |
("CODE;*.*.*" "/lib/prog/"))) |
| 156 |
|
| 157 |
;;;Sample use of that logical pathname. The return value |
| 158 |
;;;is implementation-dependent. |
| 159 |
(translate-logical-pathname "prog:code;documentation.lisp") |
| 160 |
⇒ #P"/lib/prog/docum.lisp" |
| 161 |
|
| 162 |
;;;For Unix with 14-character file names, using .l as the type |
| 163 |
;;;The second translation shortens the compiled file type to .b |
| 164 |
(setf (logical-pathname-translations "prog") |
| 165 |
`(("**;*.LISP.*" ,(logical-pathname "PROG:**;*.L.*")) |
| 166 |
(,(compile-file-pathname (logical-pathname "PROG:**;*.LISP.*")) |
| 167 |
,(logical-pathname "PROG:**;*.B.*")) |
| 168 |
("CODE;DOCUMENTATION.*.*" "/lib/prog/documentatio.*") |
| 169 |
("CODE;*.*.*" "/lib/prog/"))) |
| 170 |
|
| 171 |
;;;Sample use of that logical pathname. The return value |
| 172 |
;;;is implementation-dependent. |
| 173 |
(translate-logical-pathname "prog:code;documentation.lisp") |
| 174 |
⇒ #P"/lib/prog/documentatio.l" |
| 175 |
|
| 176 |
;;;For a Cray with 6 character names and no directories, types, or versions. |
| 177 |
(setf (logical-pathname-translations "prog") |
| 178 |
(let ((l '(("MAIN" "PGMN") |
| 179 |
("AUXILIARY" "PGAUX") |
| 180 |
("DOCUMENTATION" "PGDOC"))) |
| 181 |
(logpath (logical-pathname "prog:code;")) |
| 182 |
(phypath (pathname "XXX"))) |
| 183 |
(append |
| 184 |
;; Translations for source files |
| 185 |
(mapcar #'(lambda (x) |
| 186 |
(let ((log (first x)) |
| 187 |
(phy (second x))) |
| 188 |
(list (make-pathname :name log |
| 189 |
:type "LISP" |
| 190 |
:version :wild |
| 191 |
:defaults logpath) |
| 192 |
(make-pathname :name phy |
| 193 |
:defaults phypath)))) |
| 194 |
l) |
| 195 |
;; Translations for compiled files |
| 196 |
(mapcar #'(lambda (x) |
| 197 |
(let* ((log (first x)) |
| 198 |
(phy (second x)) |
| 199 |
(com (compile-file-pathname |
| 200 |
(make-pathname :name log |
| 201 |
:type "LISP" |
| 202 |
:version :wild |
| 203 |
:defaults logpath)))) |
| 204 |
(setq phy (concatenate 'string phy "B")) |
| 205 |
(list com |
| 206 |
(make-pathname :name phy |
| 207 |
:defaults phypath)))) |
| 208 |
l)))) |
| 209 |
|
| 210 |
;;;Sample use of that logical pathname. The return value |
| 211 |
;;;is implementation-dependent. |
| 212 |
(translate-logical-pathname "prog:code;documentation.lisp") |
| 213 |
⇒ #P"PGDOC" |
| 214 |
</pre></div> |
| 215 |
|
| 216 |
<span id="Exceptional-Situations_003a_003a-176"></span><h4 class="subsubheading">Exceptional Situations::</h4> |
| 217 |
|
| 218 |
<p>If <i>host</i> is incorrectly supplied, |
| 219 |
an error of <i>type</i> <b>type-error</b> is signaled. |
| 220 |
</p> |
| 221 |
<span id="See-Also_003a_003a-416"></span><h4 class="subsubheading">See Also::</h4> |
| 222 |
|
| 223 |
<p><b>logical-pathname</b>, |
| 224 |
</p> |
| 225 |
<p><a href="Pathnames-as-Filenames.html">Pathnames as Filenames</a> |
| 226 |
</p> |
| 227 |
<span id="Notes_003a_003a-278"></span><h4 class="subsubheading">Notes::</h4> |
| 228 |
|
| 229 |
<p>Implementations can define additional <i>functions</i> |
| 230 |
that operate on <i>logical pathname</i> hosts, |
| 231 |
for example to specify additional translation rules or options. |
| 232 |
</p> |
| 233 |
<hr> |
| 234 |
<div class="header"> |
| 235 |
<p> |
| 236 |
Next: <a href="logical_002dpathname.html" accesskey="n" rel="next">logical-pathname</a>, Previous: <a href="load_002dlogical_002dpathname_002dtranslations.html" accesskey="p" rel="prev">load-logical-pathname-translations</a>, Up: <a href="Filenames-Dictionary.html" accesskey="u" rel="up">Filenames Dictionary</a> </p> |
| 237 |
</div> |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
</body> |
| 242 |
</html> |