Re: Simple question about directories



In article <1188385324.814407.3040@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
alessiostalla@xxxxxxxxx wrote:

I can't figure this out, even reading the hyperspec or searching this
group. I know the answer is probably simple... anyway, here's the
question:

I have a pathname object specifiying a directory (e.g. "/home/
alessio/"). Suppose I want to obtain from it a new pathname object
representing a subdirectory (e.g. "/home/alessio/lisp/"). Is there a
good, portable way of doing this?

I use this:


(let ((pathname (pathname "rj:>joswig>")))
(make-pathname :defaults pathname
:directory (append (pathname-directory pathname)
(list "lisp"))))

#P"RJ:>joswig>lisp>"

You can easily make it a utility function...



I'm aware of various examples of code to portably list all
subdirectories of a given dir. But if I understand correctly the
directory component of a pathname can be an implementation- and os-
dependent string identifying the directory, as such it can contain,
besides the directory name, other things like pathname separators,
parent directories etc. so it's not feasible to portably extract from
it the actual directory name. Am I complicating things more than it's
needed?

Thanks for any help...
Alessio S.

--
http://lispm.dyndns.org
.