User Tools


Function PARSE-NAMESTRING

Syntax

  • parse-namestring thing &optional host default-pathname &key start end junk-allowedpathname, position

Arguments and Values

  • default-pathname - a pathname designator. The default is the value of *default-pathname-defaults*.
  • start, end - bounding index designators of thing. The defaults for start and end/are 0 and nil, respectively. * junk-allowed - a generalized boolean. The default is false. * pathname - a pathname, or nil. * position - a bounding index designator for thing. ====Description==== Converts thing into a pathname. The host supplies a host name with respect to which the parsing occurs. If thing is a stream associated with a file, processing proceeds as if the pathname used to open that file had been supplied instead. If thing is a pathname, the host and the host component of thing are compared. If they match, two values are immediately returned: thing and start; otherwise (if they do not match), an error is signaled. Otherwise (if thing is a string), parse-namestring parses the name of a file within the substring of thing bounded by start and end. If thing is a string then the substring of thing bounded by start and end is parsed into a pathname as follows: * If host is a logical host then thing is parsed as a logical pathname namestring on the host. * If host is nil and thing is a syntactically valid logical pathname namestring containing an explicit host, then it is parsed as a logical pathname namestring. * If host is nil, default-pathname is a logical pathname, and thing is a syntactically valid logical pathname namestring without an explicit host, then it is parsed as a logical pathname namestring on the host that is the host component of default-pathname. * Otherwise, the parsing of thing is implementation-defined. In the first of these cases, the host portion of the logical pathname namestring and its following colon are optional. If the host portion of the namestring and host are both present and do not match, an error is signaled. If junk-allowed is true, then the primary value is the pathname parsed or, if no syntactically correct pathname was seen, nil. If junk-allowed is false, then the entire substring is scanned, and the primary value is the pathname parsed. In either case, the secondary value is the index into thing of the delimiter that terminated the parse, or the index beyond the substring if the parse terminated at the end of the substring (as will always be the case if junk-allowed is false). Parsing a null string always succeeds, producing a pathname with all components (except the host) equal to nil. If thing contains an explicit host name and no explicit device name, then it is implementation-defined whether parse-namestring will supply the standard default device for that host as the device component of the resulting pathname. ====Examples==== <blockquote> (defparameter *q* (parse-namestring "test")) <r>*Q*</r> *q* <r>#S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test" :TYPE NIL :VERSION NIL) </r> (pathnamep *q*) <r>true </r> (parse-namestring "test") <r>#S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test" :TYPE NIL :VERSION NIL) 4 </r> (defparameter *s* (open xxx)) <r>#<Input File Stream...> </r> (parse-namestring *s*) <r>#S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME xxx :TYPE NIL :VERSION NIL) 0 </r> (parse-namestring "test" nil nil :start 2 :end 4) <r>#S(PATHNAME ...) 15 </r> (parse-namestring "foo.lisp") <r>#P"foo.lisp" </r> </blockquote> ====Affected By==== None. ====Exceptional Situations==== If junk-allowed is false, an error of type parse-error is signaled if thing does not consist entirely of the representation of a pathname, possibly surrounded on either side by whitespace characters if that is appropriate to the cultural conventions of the implementation. If host is supplied and not nil, and thing contains a manifest host name, an error of type error is signaled if the hosts do not match. If thing is a logical pathname namestring and if the host portion of the namestring and host are both present and do not match, an error of type error is signaled. ====See Also==== * System Class PATHNAME * System Class LOGICAL-PATHNAME * {\secref\FileSystemConcepts} * {\secref\UnspecificComponent} * {\secref\PathnamesAsFilenames} ====Notes==== None. \issue{PATHNAME-PRINT-READ:SHARPSIGN-P} \issue{PATHNAME-LOGICAL:ADD} \issue{PATHNAME-LOGICAL:ADD} \issue{FILE-OPEN-ERROR:SIGNAL-FILE-ERROR} \issue{PATHNAME-SYMBOL} \issue{PATHNAME-LOGICAL:ADD} \issue{PATHNAME-LOGICAL:ADD} \issue{PATHNAME-UNSPECIFIC-COMPONENT:NEW-TOKEN} \issue{SUBSEQ-OUT-OF-BOUNDS} \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL} \issue{PATHNAME-STREAM} \issue{PATHNAME-SYMBOL} \issue{PATHNAME-LOGICAL:ADD} \issue{PATHNAME-HOST-PARSING:RECOGNIZE-LOGICAL-HOST-NAMES}