User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:namestring [2019/06/15 02:00]
cl:functions:namestring [2019/08/17 15:00] (current)
Line 1: Line 1:
 +====== Function NAMESTRING, FILE-NAMESTRING,​ DIRECTORY-NAMESTRING,​ HOST-NAMESTRING,​ ENOUGH-NAMESTRING ======
 +
 +====Syntax====
 +  * **namestring** //​pathname//​ → //​namestring//​
 +  * **file-namestring** //​pathname//​ → //​namestring// ​
 +  * **directory-namestring** //​pathname//​ → //​namestring// ​
 +  * **host-namestring** //​pathname//​ → //​namestring//​
 +  * **enough-namestring** //​pathname//​ ''&​optional''​ //​defaults//​ → //​namestring//​
 +
 +====Arguments and Values====
 +  * //​pathname//​ - a //​[[CL:​Glossary:​pathname designator]]//​.
 +  * //​defaults//​ - a //​[[CL:​Glossary:​pathname designator]]//​. The default is the //​[[CL:​Glossary:​value]]//​ of **[[CL:​Variables:​star-default-pathname-defaults|*default-pathname-defaults*]]**.
 +  * //​namestring//​ - a //​[[CL:​Glossary:​string]]//​ or **[[CL:​Constant Variables:​nil]]**.
 +
 +====Description====
 +These functions convert //​pathname//​ into a namestring.
 +
 +The name represented by //​pathname//​ is returned as a //​[[CL:​Glossary:​namestring]]//​ in an //​[[CL:​Glossary:​implementation-dependent]]//​ canonical form.
 +
 +**namestring** returns the full form of //​pathname//​.
 +
 +**file-namestring** returns just the name, type, and version components of //​pathname//​.
 +  ​
 +**directory-namestring** returns the directory name portion.
 +  ​
 +**host-namestring** returns the host name.
 +  ​
 +**enough-namestring** returns an abbreviated namestring that is just sufficient to identify the file named by //​pathname//​ when considered relative to the //​defaults//​. It is required that:
 +
 +<​blockquote> ​
 +([[CL:​Functions:​merge-pathnames]] (enough-namestring //​pathname//​ //​defaults//​) //​defaults//​) ​
 +  ≡ ([[CL:​Functions:​merge-pathnames]] ([[CL:​Functions:​parse-namestring]] //​pathname//​ [[CL:​Constant Variables:​nil]] //​defaults//​) //​defaults//​) ​
 +</​blockquote> ​
 +
 +in all cases, and the result of **[[CL:​Functions:​enough-namestring]]** is the shortest reasonable //​[[CL:​Glossary:​string]]//​ that will satisfy this criterion.
 +
 +It is not necessarily possible to construct a valid //​[[CL:​Glossary:​namestring]]//​ by concatenating some of the three shorter //​[[CL:​Glossary:​namestring|namestrings]]//​ in some order.
 +
 +====Examples====
 +In the below example, the //​[[CL:​Glossary:​return value]]// of the first **[[CL:​Functions:​pathname-directory]]** call depends on the //​[[CL:​Glossary:​implementation]]//​ and the //​[[CL:​Glossary:​file system]]//.
 +
 +<​blockquote>​
 +([[CL:​Functions:​pathname-directory]] *default-pathname-defaults*) <​r>​(:​ABSOLUTE "​home"​ "​kathy"​)</​r>​
 +(namestring "​getty"​) <​r>"​getty"</​r>​
 +([[CL:​Macros:​defparameter]] *q* 
 +  ([[CL:​Functions:​make-pathname]] :host "​kathy" ​
 +                 :​directory (pathname-directory *default-pathname-defaults*)
 +                 :name "​getty"​)) <​r>​*Q*</​r>​
 +*q*
 +<​r>#​S(PATHNAME :HOST "​kathy"​ :DEVICE NIL :DIRECTORY (:ABSOLUTE "​home"​ "​kathy"​)
 +            :NAME "​getty"​ :TYPE NIL :VERSION NIL) </r>
 +(file-namestring *q*) <​r>"​getty"​ </r>
 +(directory-namestring *q*) <​r>​(:​ABSOLUTE "​home"​ "​kathy"​)</​r>​
 +(host-namestring *q*) <​r>"​kathy"​ </r>
 +</​blockquote>​
 +
 +Using Unix syntax and the //​[[CL:​Glossary:​wildcard]]//​ conventions used by the particular version of Unix on which this example was created: ​
 +
 +<​blockquote>​
 +(namestring ([[CL:​Functions:​translate-pathname]] "/​usr/​dmr/​hacks/​frob.l" ​
 +                                "/​usr/​d*/​hacks/​*.l" ​
 +                                "/​usr/​d*/​backup/​hacks/​backup-*.*"​)) ​
 +<​r>"/​usr/​dmr/​backup/​hacks/​backup-frob.l"​ </r>
 +(namestring ([[CL:​Functions:​translate-pathname]] "/​usr/​dmr/​hacks/​frob.l" ​
 +                                "/​usr/​d*/​hacks/​fr*.l" ​
 +                                "/​usr/​d*/​backup/​hacks/​backup-*.*"​)) ​
 +<​r>"/​usr/​dmr/​backup/​hacks/​backup-ob.l"</​r>​
 +</​blockquote>​
 +
 +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. ​
 +
 +<​blockquote>​
 +(namestring ([[CL:​Functions:​translate-pathname]] "​U:/​usr/​dmr/​hacks/​frob.l" ​
 +                                "​U:/​usr/​d*/​hacks/​*.l" ​
 +                                "​V:​SYS''​DISK:​[D*.BACKUP.HACKS]BACKUP-*.*"​)) ​
 +<​r>"​V:​SYS''​DISK:​[DMR.BACKUP.HACKS]BACKUP-FROB.LSP"​ </r>
 +(namestring ([[CL:​Functions:​translate-pathname]] "​U:/​usr/​dmr/​hacks/​frob.l" ​
 +                                "​U:/​usr/​d*/​hacks/​fr*.l" ​
 +                                "​V:​SYS''​DISK:​[D*.BACKUP.HACKS]BACKUP-*.*"​)) ​
 +<​r>"​V:​SYS''​DISK:​[DMR.BACKUP.HACKS]BACKUP-OB.LSP"</​r>​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​truename|Function TRUENAME]]**
 +  * **[[CL:​Functions:​merge-pathnames|Function MERGE-PATHNAMES]]**
 +  * **[[CL:​Types:​pathname|System Class PATHNAME]]**
 +  * **[[CL:​Types:​logical-pathname|System Class LOGICAL-PATHNAME]]**
 +  * {\secref\FileSystemConcepts}
 +  * {\secref\PathnamesAsFilenames}
 +
 +====Notes====
 +None.
 +
 +\issue{PATHNAME-STREAM} \issue{PATHNAME-SYMBOL} \issue{PATHNAME-SYMBOL} \issue{PATHNAME-WILD:​NEW-FUNCTIONS} \issue{PATHNAME-LOGICAL:​ADD} \issue{FILE-OPEN-ERROR:​SIGNAL-FILE-ERROR}