Next: , Up: Pathnames   [Contents][Index]


2.16.1 Unix Pathnames

Unix pathnames are always parsed with a unix-host object as the host and nil as the device. The last two dots (.) in the namestring mark the type and version, however if the first character is a dot, it is considered part of the name. If the last character is a dot, then the pathname has the empty-string as its type. The type defaults to nil and the version defaults to :newest.

(defun parse (x)
  (values (pathname-name x) (pathname-type x) (pathname-version x)))

(parse "foo") ⇒ "foo", NIL, NIL
(parse "foo.bar") ⇒ "foo", "bar", NIL
(parse ".foo") ⇒ ".foo", NIL, NIL
(parse ".foo.bar") ⇒ ".foo", "bar", NIL
(parse "..") ⇒ NIL, NIL, NIL
(parse "foo.") ⇒ "foo", "", NIL
(parse "foo.bar.~1~") ⇒ "foo", "bar", 1
(parse "foo.bar.baz") ⇒ "foo.bar", "baz", NIL

The directory of pathnames beginning with a slash (or a search-list, see search-lists) is starts :absolute, others start with :relative. The .. directory is parsed as :up; there is no namestring for :back:

(pathname-directory "/usr/foo/bar.baz") ⇒ (:ABSOLUTE "usr" "foo")
(pathname-directory "../foo/bar.baz") ⇒ (:RELATIVE :UP "foo")

Next: Wildcard Pathnames, Up: Pathnames   [Contents][Index]