1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/f_merge_.htm
2024-04-01 10:24:07 +02:00

74 lines
11 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Function MERGE-PATHNAMES</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="f_tr_pn.htm">
<LINK REL=UP HREF="c_filena.htm">
<LINK REL=NEXT HREF="20_.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="f_tr_pn.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_filena.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="20_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="merge-pathnames"><I>Function</I> <B>MERGE-PATHNAMES</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>merge-pathnames</B> <I>pathname <TT>&amp;optional</TT> default-pathname default-version</I><P> =&gt; <I>merged-pathname</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>pathname</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#pathname_designator"><I>pathname designator</I></A>. <P>
<I>default-pathname</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#pathname_designator"><I>pathname designator</I></A>. The default is the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_defaul.htm#STdefault-pathname-defaultsST"><B>*default-pathname-defaults*</B></A>. <P>
<I>default-version</I>---a <A REL=DEFINITION HREF="26_glo_v.htm#valid_pathname_version"><I>valid pathname version</I></A>. The default is <TT>:newest</TT>. <P>
<I>merged-pathname</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A>. <P>
<P><B>Description:</B><P>
<P>
Constructs a <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A> from <I>pathname</I> by filling in any unsupplied components with the corresponding values from <I>default-pathname</I> and <I>default-version</I>. <P>
Defaulting of pathname components is done by filling in components taken from another <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></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 REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_cmp__1.htm#compile-file-pathname"><B>compile-file-pathname</B></A>. <P>
If no version is supplied, <I>default-version</I> is used. If <I>default-version</I> is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, the version component will remain unchanged. <P>
If <I>pathname</I> explicitly specifies a host and not a device, and if the host component of <I>default-pathname</I> matches the host component of <I>pathname</I>, then the device is taken from the <I>default-pathname</I>; otherwise the device will be the default file device for that host. If <I>pathname</I> does not specify a host, device, directory, name, or type, each such component is copied from <I>default-pathname</I>. If <I>pathname</I> does not specify a name, then the version, if not provided, will come from <I>default-pathname</I>, just like the other components. If <I>pathname</I> does specify a name, then the version is not affected by <I>default-pathname</I>. If this process leaves the version missing, the <I>default-version</I> 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 <I>default-pathname</I>. <P>
If <I>pathname</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>, <I>pathname</I> effectively becomes <TT>(pathname </TT><I>pathname</I><TT>)</TT>. <A REL=DEFINITION HREF="#merge-pathnames"><B>merge-pathnames</B></A> can be used on either an open or a closed <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>. <P>
If <I>pathname</I> is a <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></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>
<A REL=DEFINITION HREF="#merge-pathnames"><B>merge-pathnames</B></A> recognizes a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> when <I>default-pathname</I> is a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A>, or when the <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> begins with the name of a defined <A REL=DEFINITION HREF="26_glo_l.htm#logical_host"><I>logical host</I></A> followed by a <A REL=DEFINITION HREF="26_glo_c.htm#colon"><I>colon</I></A>. In the first of these two cases, the host portion of the <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> and its following <A REL=DEFINITION HREF="26_glo_c.htm#colon"><I>colon</I></A> are optional. <P>
<A REL=DEFINITION HREF="#merge-pathnames"><B>merge-pathnames</B></A> returns a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A> if and only if its first argument is a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A>, or its first argument is a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A> <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> with an explicit host, or its first argument does not specify a host and the <I>default-pathname</I> is a <A REL=DEFINITION HREF="26_glo_l.htm#logical_pathname"><I>logical pathname</I></A>. <P>
<A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>Pathname</I></A> merging treats a relative directory specially. If <TT>(pathname-directory </TT><I>pathname</I><TT>)</TT> is a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> whose <A REL=DEFINITION HREF="26_glo_c.htm#car"><I>car</I></A> is <TT>:relative</TT>, and <TT>(pathname-directory </TT><I>default-pathname</I><TT>)</TT> is a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A>, then the merged directory is the value of <P>
<PRE>
(append (pathname-directory default-pathname)
(cdr ;remove :relative from the front
(pathname-directory pathname)))
</PRE>
</TT> except that if the resulting <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> contains a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> or <TT>:wild</TT> immediately followed by <TT>:back</TT>, both of them are removed. This removal of redundant <TT>:back</TT> <A REL=DEFINITION HREF="26_glo_k.htm#keyword"><I>keywords</I></A> is repeated as many times as possible. If <TT>(pathname-directory </TT><I>default-pathname</I><TT>)</TT> is not a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> or <TT>(pathname-directory </TT><I>pathname</I><TT>)</TT> is not a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> whose <A REL=DEFINITION HREF="26_glo_c.htm#car"><I>car</I></A> is <TT>:relative</TT>, the merged directory is <TT>(or (pathname-directory </TT><I>pathname</I><TT>) (pathname-directory </TT><I>default-pathname</I><TT>))</TT> <P>
<A REL=DEFINITION HREF="#merge-pathnames"><B>merge-pathnames</B></A> maps customary case in <I>pathname</I> into customary case in the output <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A>. <P>
<P><B>Examples:</B><P>
<PRE>
(merge-pathnames &quot;CMUC::FORMAT&quot;
&quot;CMUC::PS:&lt;LISPIO&gt;.FASL&quot;)
=&gt; #P&quot;CMUC::PS:&lt;LISPIO&gt;FORMAT.FASL.0&quot;
</PRE>
</TT> <P>
<P><B>Affected By:</B> None.
<P>
<P><B>Exceptional Situations:</B> None.
<P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="v_defaul.htm#STdefault-pathname-defaultsST"><B>*default-pathname-defaults*</B></A>, <A REL=DEFINITION HREF="t_pn.htm#pathname"><B>pathname</B></A>, <A REL=DEFINITION HREF="t_logica.htm#logical-pathname"><B>logical-pathname</B></A>, <A REL=CHILD HREF="20_a.htm">Section 20.1 (File System Concepts)</A>, <A REL=CHILD HREF="19_ab.htm">Section 19.1.2 (Pathnames as Filenames)</A> <P>
<P><B>Notes:</B><P>
<P>
The net effect is that if just a name is supplied, the host, device, directory, and type will come from <I>default-pathname</I>, but the version will come from <I>default-version</I>. If nothing or just a directory is supplied, the name, type, and version will come from <I>default-pathname</I> together. <P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss157.htm">FILE-OPEN-ERROR:SIGNAL-FILE-ERROR</A><LI> <A REL=CHILD HREF="../Issues/iss256.htm">PATHNAME-COMPONENT-CASE:KEYWORD-ARGUMENT</A><LI> <A REL=CHILD HREF="../Issues/iss263.htm">PATHNAME-SUBDIRECTORY-LIST:NEW-REPRESENTATION</A><LI> <A REL=CHILD HREF="../Issues/iss258.htm">PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES</A><LI> <A REL=CHILD HREF="../Issues/iss259.htm">PATHNAME-LOGICAL:ADD</A><LI> <A REL=CHILD HREF="../Issues/iss053.htm">CLOSED-STREAM-OPERATIONS:ALLOW-INQUIRY</A><LI> <A REL=CHILD HREF="../Issues/iss060.htm">COMPILE-FILE-OUTPUT-FILE-DEFAULTS:INPUT-FILE</A><LI> <A REL=CHILD HREF="../Issues/iss266.htm">PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN</A><LI> <A REL=CHILD HREF="../Issues/iss261.htm">PATHNAME-STREAM</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>