parse-namestring
parse-namestring thing &optional host default-pathname &key start end junk-allowed → pathname, position
thing—a string, a pathname, or a stream associated with a file. This isn't quite right. The start/end thing puts a wrinkle in things. -kmp 29-Aug-93 \term{pathname designator}
Added NIL here because the Description seemed to permit it. -kmp 29-Aug-93host—a valid pathname host, a logical host, or nil.
default-pathname—a pathname designator. The default is the value of *default-pathname-defaults*.
This should go without saying!! -kmp 29-Aug-93 It is an error if optional arguments do not accompany keyword arguments.
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.
position—a bounding index designator for thing.
23.1.2 9 23.1.2 10Converts thing into a pathname.
The host supplies a host name with respect to which the parsing occurs. Removed per X3J13. -kmp 05-Oct-93 If \param{host} is \nil, then the host name is extracted from \param{default-pathname} and used to determine the syntax convention.
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. 23.1.2 15 If \param{thing} is not a \term{string}, then \param{start} is returned as the second value.If they match, two values are immediately returned: thing and start; otherwise (if they do not match), an error is signaled.
If \param{thing} is a \term{symbol}, the print name is used.
23.1.2 11Otherwise (if thing is a string), parse-namestring parses the name of a file within the substring of thing bounded by start and end.
Replaced (again) per X3J13. -kmp 05-Oct-93 \param{thing} is recognized as a \term{logical pathname} \term{namestring} when \param{host} is a \term{logical host} (or a \term{string} that names a defined \term{logical host}), \param{default-pathname} is a \term{logical pathname}, Per X3J13. -kmp 05-Oct-93 or the substring begins with the name of a defined \term{logical host} followed by a \term{colon}. or \param{host} is unsupplied and \param{thing} is a \term{string} that is a syntactically valid \term{logical pathname} \term{namestring} containing an explicit host.If thing is a string then I added this. -kmp 05-Oct-93 itthe substring of thing bounded by start and end is parsed into a pathname as follows:
nil and thing is a syntactically valid logical pathname namestring containing an explicit host, then it is parsed as a logical pathname namestring.
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 Wording simplified by me. -kmp 05-Oct-93
with the host from \param{default-pathname}
used as the host for the resulting \term{pathname}. on the host that is the host component of default-pathname.
In the first Changed to match wording voted by X3J13 above. -kmp 05-Oct-93 twoof these Don't bother trying to count. -kmp 05-Oct-93 threecases, the host portion of the logical pathname namestring and its following colon are optional. Whether a host argument is logical if it is a \term{string} that is \term{string equal} to a \term{logical pathname} host name is \term{implementation-defined}.
If the host portion of the namestring and host are both present and do not match, an error is signaled.
23.1.2 12If junk-allowed is true, then the primary value is the pathname parsed or, if no syntactically correct pathname was seen, nil. 23.1.2 13If junk-allowed is false, then the entire substring is scanned, and the primary value is the pathname parsed.
23.1.2 14In 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).
23.1.2 16Parsing a null string always succeeds, producing a pathname with all components (except the host) equal to nil.
23.1.2 18If 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.
(setq q (parse-namestring "test"))
→ #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test"
:TYPE NIL :VERSION NIL)
(pathnamep q) → true
(parse-namestring "test")
→ #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME "test"
:TYPE NIL :VERSION NIL), 4
(setq s (open xxx)) → #<Input File Stream...>
(parse-namestring s)
→ #S(PATHNAME :HOST NIL :DEVICE NIL :DIRECTORY NIL :NAME xxx
:TYPE NIL :VERSION NIL), 0
(parse-namestring "test" nil nil :start 2 :end 4 )
→ #S(PATHNAME ...), 15
(parse-namestring "foo.lisp")
→ #P"foo.lisp"
None.
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 whitespace1 characters if that is appropriate to the cultural conventions of the implementation.
23.1.2 17If 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.
This is implied by stream associated with a file. -kmp 29-Aug-93 \issue{PATHNAME-STREAM} It is an error if \param{thing} is a \term{stream} that is created with \funref{make-two-way-stream}, \funref{make-echo-stream}, \funref{make-broadcast-stream}, \funref{make-concatenated-stream}, \funref{make-string-input-stream}, \funref{make-string-output-stream}. \endissue{PATHNAME-STREAM}
pathname, logical-pathname, Section 20.1 (File System Concepts), Section 19.2.2.2.3 (:UNSPECIFIC as a Component Value), Section 19.1.2 (Pathnames as Filenames)
None.