User Tools


Function NAMESTRING, FILE-NAMESTRING, DIRECTORY-NAMESTRING, HOST-NAMESTRING, ENOUGH-NAMESTRING

Syntax

  • namestring pathnamenamestring
  • file-namestring pathnamenamestring
  • directory-namestring pathnamenamestring
  • host-namestring pathnamenamestring
  • enough-namestring pathname &optional defaultsnamestring

Arguments and Values

Description

These functions convert pathname into a namestring.

The name represented by pathname is returned as a namestring in an 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:

(merge-pathnames (enough-namestring pathname defaults) defaults) ≡ (merge-pathnames (parse-namestring pathname nil defaults) defaults)

in all cases, and the result of enough-namestring is the shortest reasonable string that will satisfy this criterion.

It is not necessarily possible to construct a valid namestring by concatenating some of the three shorter namestrings in some order.

Examples

In the below example, the return value of the first pathname-directory call depends on the implementation and the file system.

(pathname-directory *default-pathname-defaults*)

(:ABSOLUTE "home" "kathy")

(namestring "getty")

"getty"

(defparameter *q* (make-pathname :host "kathy" :directory (pathname-directory *default-pathname-defaults*) :name "getty"))

*Q*

*q*

#S(PATHNAME :HOST "kathy" :DEVICE NIL :DIRECTORY (:ABSOLUTE "home" "kathy") :NAME "getty" :TYPE NIL :VERSION NIL)

(file-namestring *q*)

"getty"

(directory-namestring *q*)

(:ABSOLUTE "home" "kathy")

(host-namestring *q*)

"kathy"

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:SYSDISK:[D*.BACKUP.HACKS]BACKUP-*.*")) <r>"V:SYSDISK:[DMR.BACKUP.HACKS]BACKUP-FROB.LSP" </r> (namestring (translate-pathname "U:/usr/dmr/hacks/frob.l" "U:/usr/d*/hacks/fr*.l" "V:SYSDISK:[D*.BACKUP.HACKS]BACKUP-*.*")) <r>"V:SYSDISK:[DMR.BACKUP.HACKS]BACKUP-OB.LSP"</r>

Affected By

None.

Exceptional Situations

None.

See Also

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}