519 lines
12 KiB
HTML
519 lines
12 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<HTML LANG="en-us"
|
||
|
><HEAD
|
||
|
><TITLE
|
||
|
>merge-pathnames | Common Lisp Nova Spec</TITLE
|
||
|
><META CHARSET="US-ASCII"
|
||
|
><LINK REL="canonical" HREF="f_merge-pathnames.html"
|
||
|
><LINK REL="next" HREF="20_Files.html" TYPE="text/html" TITLE="20. Files"
|
||
|
><LINK REL="prev" HREF="f_translate-pathname.html" TYPE="text/html" TITLE="translate-pathname"
|
||
|
><LINK REL="up" HREF="19_4_Filenames_Dictionary.html" TYPE="text/html" TITLE="19.4 Filenames Dictionary"
|
||
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
||
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
||
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
||
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
||
|
></SCRIPT
|
||
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
||
|
></SCRIPT
|
||
|
></HEAD
|
||
|
><BODY
|
||
|
><DIV
|
||
|
><DIV CLASS="topnav"
|
||
|
><DIV CLASS="breadcrumb"
|
||
|
><SPAN CLASS="breadcrumb-item"
|
||
|
><A HREF="index.html"
|
||
|
>Common Lisp Nova Spec</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="19_Filenames.html"
|
||
|
>19. Filenames</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="19_4_Filenames_Dictionary.html"
|
||
|
>19.4 Filenames Dictionary</A
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="breadcrumb-item"
|
||
|
>→ <A HREF="f_merge-pathnames.html"
|
||
|
>merge-pathnames</A
|
||
|
></SPAN
|
||
|
></DIV
|
||
|
><DIV CLASS="apropos"
|
||
|
><DIV CLASS="apropos-io"
|
||
|
><A HREF="f_translate-pathname.html" CLASS="prev"
|
||
|
>←</A
|
||
|
><SPAN ID="apropos-label"
|
||
|
>Apropos </SPAN
|
||
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
||
|
><A HREF="20_Files.html" CLASS="next"
|
||
|
>→</A
|
||
|
></DIV
|
||
|
><DIV ID="apropos-res"
|
||
|
></DIV
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><DIV CLASS="matter"
|
||
|
><DIV CLASS="com"
|
||
|
><DIV CLASS="begincom"
|
||
|
><HR
|
||
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
||
|
><TR
|
||
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
||
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="merge-pathnames"
|
||
|
></SPAN
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
></TD
|
||
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
||
|
><I
|
||
|
>Function</I
|
||
|
></TD
|
||
|
></TR
|
||
|
></TABLE
|
||
|
><HR
|
||
|
></DIV
|
||
|
><UL CLASS="subtoc"
|
||
|
></UL
|
||
|
><DL
|
||
|
><DT
|
||
|
><B
|
||
|
>Syntax</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><DIV
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
> <SPAN CLASS="cmssi"
|
||
|
>pathname</SPAN
|
||
|
> <SPAN CLASS="cmtt"
|
||
|
>&optional</SPAN
|
||
|
> <SPAN CLASS="cmssi"
|
||
|
>default-pathname</SPAN
|
||
|
> <SPAN CLASS="cmssi"
|
||
|
>default-version</SPAN
|
||
|
> </DIV
|
||
|
><DIV
|
||
|
><SPAN CLASS="cmsy"
|
||
|
><SPAN CLASS="arrow"
|
||
|
>→</SPAN
|
||
|
></SPAN
|
||
|
> <SPAN CLASS="cmssi"
|
||
|
>merged-pathname</SPAN
|
||
|
></DIV
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Arguments and Values</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
><VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> — a <A HREF="26_1_Glossary.html#pathname_designator"
|
||
|
><EM CLASS="term"
|
||
|
>pathname designator</EM
|
||
|
></A
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
><VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> — a <A HREF="26_1_Glossary.html#pathname_designator"
|
||
|
><EM CLASS="term"
|
||
|
>pathname designator</EM
|
||
|
></A
|
||
|
>. The default is the <A HREF="26_1_Glossary.html#value"
|
||
|
><EM CLASS="term"
|
||
|
>value</EM
|
||
|
></A
|
||
|
> of <A HREF="v_default-pathname-defaults.html" CLASS="misc"
|
||
|
><B
|
||
|
>*default-pathname-defaults*</B
|
||
|
></A
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
><VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
> — a <A HREF="26_1_Glossary.html#valid_pathname_version"
|
||
|
><EM CLASS="term"
|
||
|
>valid pathname version</EM
|
||
|
></A
|
||
|
>. The default is <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:newest</SPAN
|
||
|
></SPAN
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
><VAR CLASS="param"
|
||
|
>merged-pathname</VAR
|
||
|
> — a <A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>pathname</EM
|
||
|
></A
|
||
|
>.</P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Description</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
>Constructs a <A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>pathname</EM
|
||
|
></A
|
||
|
> from <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> by filling in any unsupplied components with the corresponding values from <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> and <VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
>Defaulting of pathname components is done by filling in components taken from another <A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>pathname</EM
|
||
|
></A
|
||
|
>. This is especially useful for cases such as a program that has an input file and an output file. Unspecified components of the output pathname will come from the input pathname, except that the type should not default to the type of the input pathname but rather to the appropriate default type for output from the program; for example, see the <A HREF="26_1_Glossary.html#function"
|
||
|
><EM CLASS="term"
|
||
|
>function</EM
|
||
|
></A
|
||
|
> <A HREF="f_compile-file-pathname.html" CLASS="funref"
|
||
|
><B
|
||
|
>compile-file-pathname</B
|
||
|
></A
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
>If no version is supplied, <VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
> is used. If <VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
> is <SPAN CLASS="misc"
|
||
|
><B
|
||
|
>nil</B
|
||
|
></SPAN
|
||
|
>, the version component will remain unchanged. </P
|
||
|
><P CLASS="j"
|
||
|
>If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> explicitly specifies a host and not a device, and if the host component of <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> matches the host component of <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>, then the device is taken from the <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>; otherwise the device will be the default file device for that host. If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> does not specify a host, device, directory, name, or type, each such component is copied from <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>. If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> does not specify a name, then the version, if not provided, will come from <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>, just like the other components. If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> does specify a name, then the version is not affected by <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>. If this process leaves the version missing, the <VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
> is used. If the host’s file name syntax provides a way to input a version without a name or type, the user can let the name and type default but supply a version different from the one in <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
>If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> is a <A HREF="26_1_Glossary.html#stream"
|
||
|
><EM CLASS="term"
|
||
|
>stream</EM
|
||
|
></A
|
||
|
>, <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> effectively becomes <CODE CLASS="f"
|
||
|
>(pathname <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>)</CODE
|
||
|
>. <A HREF="f_merge-pathnames.html" CLASS="funref"
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
></A
|
||
|
> can be used on either an open or a closed <A HREF="26_1_Glossary.html#stream"
|
||
|
><EM CLASS="term"
|
||
|
>stream</EM
|
||
|
></A
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
>If <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> is a <A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>pathname</EM
|
||
|
></A
|
||
|
> it represents the name used to open the file. This may be, but is not required to be, the actual name of the file. </P
|
||
|
><P CLASS="j"
|
||
|
><A HREF="f_merge-pathnames.html" CLASS="funref"
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
></A
|
||
|
> recognizes a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
> <A HREF="26_1_Glossary.html#namestring"
|
||
|
><EM CLASS="term"
|
||
|
>namestring</EM
|
||
|
></A
|
||
|
> when <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> is a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
>, or when the <A HREF="26_1_Glossary.html#namestring"
|
||
|
><EM CLASS="term"
|
||
|
>namestring</EM
|
||
|
></A
|
||
|
> begins with the name of a defined <A HREF="26_1_Glossary.html#logical_host"
|
||
|
><EM CLASS="term"
|
||
|
>logical host</EM
|
||
|
></A
|
||
|
> followed by a <A HREF="26_1_Glossary.html#colon"
|
||
|
><EM CLASS="term"
|
||
|
>colon</EM
|
||
|
></A
|
||
|
>. In the first of these two cases, the host portion of the <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
> <A HREF="26_1_Glossary.html#namestring"
|
||
|
><EM CLASS="term"
|
||
|
>namestring</EM
|
||
|
></A
|
||
|
> and its following <A HREF="26_1_Glossary.html#colon"
|
||
|
><EM CLASS="term"
|
||
|
>colon</EM
|
||
|
></A
|
||
|
> are optional. </P
|
||
|
><P CLASS="j"
|
||
|
><A HREF="f_merge-pathnames.html" CLASS="funref"
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
></A
|
||
|
> returns a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
> if and only if its first argument is a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
>, or its first argument is a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
> <A HREF="26_1_Glossary.html#namestring"
|
||
|
><EM CLASS="term"
|
||
|
>namestring</EM
|
||
|
></A
|
||
|
> with an explicit host, or its first argument does not specify a host and the <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> is a <A HREF="26_1_Glossary.html#logical_pathname"
|
||
|
><EM CLASS="term"
|
||
|
>logical pathname</EM
|
||
|
></A
|
||
|
>. </P
|
||
|
><P CLASS="j"
|
||
|
><A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>Pathname</EM
|
||
|
></A
|
||
|
> merging treats a relative directory specially. If <CODE CLASS="f"
|
||
|
>(pathname-directory <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>)</CODE
|
||
|
> is a <A HREF="26_1_Glossary.html#list"
|
||
|
><EM CLASS="term"
|
||
|
>list</EM
|
||
|
></A
|
||
|
> whose <A HREF="26_1_Glossary.html#car"
|
||
|
><EM CLASS="term"
|
||
|
>car</EM
|
||
|
></A
|
||
|
> is <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:relative</SPAN
|
||
|
></SPAN
|
||
|
>, and <CODE CLASS="f"
|
||
|
>(pathname-directory <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>)</CODE
|
||
|
> is a <A HREF="26_1_Glossary.html#list"
|
||
|
><EM CLASS="term"
|
||
|
>list</EM
|
||
|
></A
|
||
|
>, then the merged directory is the value of</P
|
||
|
><PRE CLASS="screen"
|
||
|
>(append (pathname-directory <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>)
|
||
|
(cdr ;remove :relative from the front
|
||
|
(pathname-directory <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>)))</PRE
|
||
|
><P CLASS="j"
|
||
|
>except that if the resulting <A HREF="26_1_Glossary.html#list"
|
||
|
><EM CLASS="term"
|
||
|
>list</EM
|
||
|
></A
|
||
|
> contains a <A HREF="26_1_Glossary.html#string"
|
||
|
><EM CLASS="term"
|
||
|
>string</EM
|
||
|
></A
|
||
|
> or <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:wild</SPAN
|
||
|
></SPAN
|
||
|
> immediately followed by <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:back</SPAN
|
||
|
></SPAN
|
||
|
>, both of them are removed. This removal of redundant <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:back</SPAN
|
||
|
></SPAN
|
||
|
> <A HREF="26_1_Glossary.html#keyword"
|
||
|
><EM CLASS="term"
|
||
|
>keywords</EM
|
||
|
></A
|
||
|
> is repeated as many times as possible. If <CODE CLASS="f"
|
||
|
>(pathname-directory <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>)</CODE
|
||
|
> is not a <A HREF="26_1_Glossary.html#list"
|
||
|
><EM CLASS="term"
|
||
|
>list</EM
|
||
|
></A
|
||
|
> or <CODE CLASS="f"
|
||
|
>(pathname-directory <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>)</CODE
|
||
|
> is not a <A HREF="26_1_Glossary.html#list"
|
||
|
><EM CLASS="term"
|
||
|
>list</EM
|
||
|
></A
|
||
|
> whose <A HREF="26_1_Glossary.html#car"
|
||
|
><EM CLASS="term"
|
||
|
>car</EM
|
||
|
></A
|
||
|
> is <SPAN CLASS="kwd"
|
||
|
><SPAN CLASS="cmtt"
|
||
|
>:relative</SPAN
|
||
|
></SPAN
|
||
|
>, the merged directory is <CODE CLASS="f"
|
||
|
>(or (pathname-directory <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
>) (pathname-directory <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>))</CODE
|
||
|
> </P
|
||
|
><P CLASS="j"
|
||
|
><A HREF="f_merge-pathnames.html" CLASS="funref"
|
||
|
><B
|
||
|
>merge-pathnames</B
|
||
|
></A
|
||
|
> maps customary case in <VAR CLASS="param"
|
||
|
>pathname</VAR
|
||
|
> into customary case in the output <A HREF="26_1_Glossary.html#pathname"
|
||
|
><EM CLASS="term"
|
||
|
>pathname</EM
|
||
|
></A
|
||
|
>.</P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Examples</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><PRE CLASS="screen"
|
||
|
> (merge-pathnames "CMUC::FORMAT"
|
||
|
"CMUC::PS:<LISPIO>.FASL")
|
||
|
<SPAN CLASS="cmsy"
|
||
|
><SPAN CLASS="arrow"
|
||
|
>→</SPAN
|
||
|
></SPAN
|
||
|
> #P"CMUC::PS:<LISPIO>FORMAT.FASL.0"</PRE
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>See Also</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
><A HREF="v_default-pathname-defaults.html" CLASS="varref"
|
||
|
><B
|
||
|
>*default-pathname-defaults*</B
|
||
|
></A
|
||
|
>, <A HREF="t_pathname.html" CLASS="typeref"
|
||
|
><B
|
||
|
>pathname</B
|
||
|
></A
|
||
|
>, <A HREF="t_logical-pathname.html" CLASS="typeref"
|
||
|
><B
|
||
|
>logical-pathname</B
|
||
|
></A
|
||
|
>, <A HREF="20_1_File_System_Concepts.html#sec_20_1" CLASS="secref"
|
||
|
><SPAN CLASS="cmr"
|
||
|
>Section</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>20.1</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>(File</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>System</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>Concepts)</SPAN
|
||
|
></A
|
||
|
>, <A HREF="19_1_Overview_of_Filenames.html#sec_19_1_2" CLASS="secref"
|
||
|
><SPAN CLASS="cmr"
|
||
|
>Section</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>19.1.2</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>(Pathnames</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>as</SPAN
|
||
|
> <SPAN CLASS="cmr"
|
||
|
>Filenames)</SPAN
|
||
|
></A
|
||
|
></P
|
||
|
></DD
|
||
|
><DT
|
||
|
><B
|
||
|
>Notes</B
|
||
|
></DT
|
||
|
><DD
|
||
|
><P CLASS="j"
|
||
|
>The net effect is that if just a name is supplied, the host, device, directory, and type will come from <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
>, but the version will come from <VAR CLASS="param"
|
||
|
>default-version</VAR
|
||
|
>. If nothing or just a directory is supplied, the name, type, and version will come from <VAR CLASS="param"
|
||
|
>default-pathname</VAR
|
||
|
> together.</P
|
||
|
></DD
|
||
|
></DL
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><DIV CLASS="footer"
|
||
|
><DIV CLASS="btmnav"
|
||
|
><A HREF="f_translate-pathname.html" CLASS="prev"
|
||
|
>←</A
|
||
|
><A HREF="20_Files.html" CLASS="next"
|
||
|
>→</A
|
||
|
></DIV
|
||
|
><DIV CLASS="trail"
|
||
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
||
|
></DIV
|
||
|
></DIV
|
||
|
><SCRIPT
|
||
|
>domReady();</SCRIPT
|
||
|
></BODY
|
||
|
></HTML
|
||
|
>
|