Subject: Re: How to get the parent directory of a pathname?
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 06 Mar 2006 22:41:24 -0600
Newsgroups: comp.lang.lisp
Message-ID: <Q--dnYxar9Bpk5DZRVn-sw@speakeasy.net>
Pascal Bourguignon  <usenet@informatimago.com> wrote:
+---------------
| public@heslin.eclipse.co.uk writes:
| > Given a directory name represented as a pathname or namestring, is there
| > a platform- and implementation-independent way to get the parent
| > directory of that directory?
| >
| > If not, is there a way that mostly works on modern platforms?
| 
| (merge-pathnames (make-pathname :directory '(:relative :up)
|                                 :defaults dirpath)
|                  dirpath)
+---------------

While technically correct, what he might get on some implementations
is, I suspect, not quite what he was hoping for, e.g., on CMUCL-19c:

    > (default-directory)

    #p"/usr/u/rpw3/src/cmd/misc/"
    > (let ((dirpath (default-directory)))
	(merge-pathnames (make-pathname :directory '(:relative :up)
					:defaults dirpath)
			 dirpath))

    #p"/usr/u/rpw3/src/cmd/misc/../"
    > 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607