Raymond Toy (RT/EUS) writes: > Walter C. Pelissero wrote: > > Raymond Toy (RT/EUS) writes: > > > > > I also now see there are a whole bunch of issues, like how should > > > > > "..a" be parsed? Is it name = "..a", type = nil, or name = ".", > > type > > > > > "a", or something else? My head hurts. > > > > > > > > I suppose anything goes as long as you are consistent. After all the > > > > concept of file type in the pathname is alien to the Unix filesystem. > > > > Though, I can immagine, different behaviours from different Lisp > > > > implementations may cause portability issues. > > > > > > Converting strings to pathnames has never been portable. If you want > > > portability, you need to use make-pathname directly. > > > > Well, there are situation where you can't use MAKE-PATHNAME yourself. > > DIRECTORY, for instance, will use it for you. That BTW was the source > > of my problems. Knowing in advance what goes in type and what goes in > > name, I believe, does simplify writing portable code. > > Where can't you use make-pathname yourself? What do you mean directory > will use it for you? (directory (make-pathname :directory '(:absolute) > :name :wild)) works for me. > > I would like to know how directory was the source of your problem. Was > it because directory returned a list of pathnames for which no > namestring could be printed, like "..."?
Yes. ~ $ cd ~/tmp ~/tmp $ mkdir foobar ~/tmp $ cd foobar ~/tmp/foobar $ touch ... ~/tmp/foobar $ lisp -init /dev/null ; Loading #P"/dev/null". CMU Common Lisp 19d Release (19D), running on zaphod.home.loc With core: /usr/home/local/cmucl-19d/lib/cmucl/lib/lisp.core Dumped on: Thu, 2006-11-23 01:30:40+01:00 on bsdcpu.csl.sri.com See <http://www.cons.org/cmucl/> for support information. Loaded subsystems: Python 1.1, target Intel x86 CLOS based on Gerd's PCL 2004/04/14 03:32:47 * (namestring (car (directory (make-pathname :directory '(:relative))))) Error in function LISP::UNPARSE-UNIX-FILE: Cannot specify a dot in a pathname name without a pathname type: "..." [Condition of type SIMPLE-ERROR] Restarts: 0: [ABORT] Return to Top-Level. Debug (type H for help) (LISP::UNPARSE-UNIX-FILE #P(:DIRECTORY (:ABSOLUTE "usr" "home" "wcp" "tmp" ...) :NAME "...")) Source: Error finding source: Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM: Source file no longer exists: target:code/filesys.lisp. 0] > BTW, I've applied your patch. It looks good, and actually fixes the > issue I raised about "..a". It is now :name ".", :type "a". This was actually my main concern, with my patch ".foo" and "..foo" are treated differently. Which one is the right one is matter of philosophical debate. On the other hand (pathname "..foo") used to produced an invalid pathname. -- walter pelissero http://www.pelissero.de
