116 lines
8.1 KiB
HTML
116 lines
8.1 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 NAMESTRING, FILE-NAMESTRING...</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="v_defaul.htm">
|
||
|
<LINK REL=UP HREF="c_filena.htm">
|
||
|
<LINK REL=NEXT HREF="f_pars_1.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="v_defaul.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="f_pars_1.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="namestring"><A NAME="file-namestring"><A NAME="directory-namestring"><A NAME="host-namestring"><A NAME="enough-namestring"><I>Function</I> <B>NAMESTRING, FILE-NAMESTRING, DIRECTORY-NAMESTRING, HOST-NAMESTRING, ENOUGH-NAMESTRING</B></A></A></A></A></A> <P>
|
||
|
<P><B>Syntax:</B><P>
|
||
|
<P>
|
||
|
|
||
|
<B>namestring</B> <I>pathname</I> => <I>namestring</I><P>
|
||
|
<P>
|
||
|
|
||
|
<B>file-namestring</B> <I>pathname</I> => <I>namestring</I><P>
|
||
|
|
||
|
<B>directory-namestring</B> <I>pathname</I> => <I>namestring</I><P>
|
||
|
|
||
|
<B>host-namestring</B> <I>pathname</I> => <I>namestring</I><P>
|
||
|
<P>
|
||
|
|
||
|
<B>enough-namestring</B> <I>pathname <TT>&optional</TT> defaults</I> => <I>namestring</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>defaults</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>namestring</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P><B>Description:</B><P>
|
||
|
<P>
|
||
|
<P>
|
||
|
These functions convert <I>pathname</I> into a namestring. The name represented by <I>pathname</I> is returned as a <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> in an <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> canonical form. <P>
|
||
|
<A REL=DEFINITION HREF="#namestring"><B>namestring</B></A> returns the full form of <I>pathname</I>. <P>
|
||
|
<A REL=DEFINITION HREF="#file-namestring"><B>file-namestring</B></A> returns just the name, type, and version components of <I>pathname</I>. <P>
|
||
|
<A REL=DEFINITION HREF="#directory-namestring"><B>directory-namestring</B></A> returns the directory name portion. <P>
|
||
|
<A REL=DEFINITION HREF="#host-namestring"><B>host-namestring</B></A> returns the host name. <P>
|
||
|
<A REL=DEFINITION HREF="#enough-namestring"><B>enough-namestring</B></A> returns an abbreviated namestring that is just sufficient to identify the file named by <I>pathname</I> when considered relative to the <I>defaults</I>. It is required that <P>
|
||
|
<PRE>
|
||
|
(merge-pathnames (enough-namestring pathname defaults) defaults)
|
||
|
== (merge-pathnames (parse-namestring pathname nil defaults) defaults)
|
||
|
</PRE>
|
||
|
</TT> in all cases, and the result of <A REL=DEFINITION HREF="#enough-namestring"><B>enough-namestring</B></A> is the shortest reasonable <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> that will satisfy this criterion. <P>
|
||
|
It is not necessarily possible to construct a valid <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestring</I></A> by concatenating some of the three shorter <A REL=DEFINITION HREF="26_glo_n.htm#namestring"><I>namestrings</I></A> in some order. <P>
|
||
|
<P><B>Examples:</B><P>
|
||
|
<P>
|
||
|
<PRE>
|
||
|
(namestring "getty")
|
||
|
=> "getty"
|
||
|
(setq q (make-pathname :host "kathy"
|
||
|
:directory
|
||
|
(pathname-directory *default-pathname-defaults*)
|
||
|
:name "getty"))
|
||
|
=> #S(PATHNAME :HOST "kathy" :DEVICE NIL :DIRECTORY directory-name
|
||
|
:NAME "getty" :TYPE NIL :VERSION NIL)
|
||
|
(file-namestring q) => "getty"
|
||
|
(directory-namestring q) => directory-name
|
||
|
(host-namestring q) => "kathy"
|
||
|
</PRE>
|
||
|
</TT>
|
||
|
<PRE>
|
||
|
;;;Using Unix syntax and the wildcard conventions used by the
|
||
|
;;;particular version of Unix on which this example was created:
|
||
|
(namestring
|
||
|
(translate-pathname "/usr/dmr/hacks/frob.l"
|
||
|
"/usr/d*/hacks/*.l"
|
||
|
"/usr/d*/backup/hacks/backup-*.*"))
|
||
|
=> "/usr/dmr/backup/hacks/backup-frob.l"
|
||
|
(namestring
|
||
|
(translate-pathname "/usr/dmr/hacks/frob.l"
|
||
|
"/usr/d*/hacks/fr*.l"
|
||
|
"/usr/d*/backup/hacks/backup-*.*"))
|
||
|
=> "/usr/dmr/backup/hacks/backup-ob.l"
|
||
|
|
||
|
;;;This is similar to the above example but uses two different hosts,
|
||
|
;;;U: which is a Unix and V: which is a VMS. Note the translation
|
||
|
;;;of file type and alphabetic case conventions.
|
||
|
(namestring
|
||
|
(translate-pathname "U:/usr/dmr/hacks/frob.l"
|
||
|
"U:/usr/d*/hacks/*.l"
|
||
|
"V:SYS$DISK:[D*.BACKUP.HACKS]BACKUP-*.*"))
|
||
|
=> "V:SYS$DISK:[DMR.BACKUP.HACKS]BACKUP-FROB.LSP"
|
||
|
(namestring
|
||
|
(translate-pathname "U:/usr/dmr/hacks/frob.l"
|
||
|
"U:/usr/d*/hacks/fr*.l"
|
||
|
"V:SYS$DISK:[D*.BACKUP.HACKS]BACKUP-*.*"))
|
||
|
=> "V:SYS$DISK:[DMR.BACKUP.HACKS]BACKUP-OB.LSP"
|
||
|
</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="f_tn.htm#truename"><B>truename</B></A>, <A REL=DEFINITION HREF="f_merge_.htm#merge-pathnames"><B>merge-pathnames</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> None.
|
||
|
<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/iss259.htm">PATHNAME-LOGICAL:ADD</A><LI> <A REL=CHILD HREF="../Issues/iss267.htm">PATHNAME-WILD:NEW-FUNCTIONS</A><LI> <A REL=CHILD HREF="../Issues/iss264.htm">PATHNAME-SYMBOL</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>
|