Re: (make-pathname :name "/root") - good/bad?



Geoffrey King wrote:
In LispWorks:
(make-pathname :name "root") ; --> #p"root"
(make-pathname :name "/root") ; --> #p"/root"

In CLISP (windows):
(make-pathname :name "root") ; --> #p"root"
(make-pathname :name "/root") ; --> error

The error is:
*** - MAKE-PATHNAME: illegal :NAME argument "/root"

If it makes a difference i don't have a directory called /root.

Which is the correct behaviour?

I think CLISP is closer to correct, at least on Unix: the name
component of a pathname is generally interpreted as the name part of a
file, as distinct from any directory part and on Unix file names in
this sense can't contain slashes. But they can on other systems, so it
depends on a lot of factors. If you want to convert a namestring into
a pathname object it's generally better to use PARSE-NAMESTRING or the
PATHNAME function, and let the system decide what parts are what.

(a clearer example of why what you're trying to do is going to lead to
bad things is something like:

(make-pathname :directory (:absolute "usr" "local") :name "/foo")

)

--tim

.



Relevant Pages

  • Re: Writing a portable copy-files
    ... I also have a couple of questions about using standard pathname ... I found that I can use (truename (make-pathname)) seems to return the ... In CLISP, I found I could use (truename (directory-namestring ... implementation dependent. ...
    (comp.lang.lisp)
  • Re: Different behavior of SBCL and CLISP on directory function
    ... I've got different behavior on sbcl and clisp in the following ... To do pathname stuff in a portable way is really difficult. ... physical file system (and not the same subset depending on the ...
    (comp.lang.lisp)
  • Re: delete-file & probe-file on directories
    ... Below is the wrapper function for PROBE-FILE from the pathnames ... form") as well as with a pathname with NIL:name and:type components ... You can see from my comments in the #+clisp section that CLISP's ... symlink in order to resolve it's truename. ...
    (comp.lang.lisp)
  • Writing a portable copy-files
    ... (defun copy-files (from wildcard to &key directories overwrite) ... (when (pathname-match-p pathname wildcard) ... On CLISP this fails saying it the file already exists. ...
    (comp.lang.lisp)
  • Re: how to convert //foo/bar to URI?
    ... pathname is implementation-defined if it begins with exactly two ... Which operating systems use such pathnames? ... reference in file.html ... know what the correct behaviour is before I go tweak the code ...
    (comp.unix.programmer)