Hi Lispers,
I have a quite trivial problem, which I cannot find the information to
solve.
I would like to change the filetype of a pathname (e.g. to nil
(unspecified) or .lisp). There is no (setf pathname-type) in my lisp,
nor is it mentioned in CLtL, although pathname-type is called an
accessor. I cannot use (merge-pathnames <filename> ".lisp") since this
will only "change" the pathname-type if it is nil (unspecified). I
cannot merge the other way, i.e. (merge-pathnames ".lisp" <filename>)
since I would like to use nil (unspecified) instead of ".lisp". I want
to avoid doing string-search since it would likely be non-portable.
Regards, Hallvard
--
Hallvard Traetteberg
Dept. of Knowledge Based Systems
Center for Industrial Research
Box 124 Blindern, 0314 Oslo 3
NORWAY
Tlf: +47 2 45 29 83 or +47 2 45 20 10
Fax: +47 2 45 20 40
Email: ···················@si.no
In article <······················@monsun.si.no> ········@monsun.si.no (Hallvard Tr{tteberg) writes:
I would like to change the filetype of a pathname (e.g. to nil
(unspecified) or .lisp). There is no (setf pathname-type) in my lisp,
nor is it mentioned in CLtL, although pathname-type is called an
accessor. I cannot use (merge-pathnames <filename> ".lisp") since this
will only "change" the pathname-type if it is nil (unspecified). I
cannot merge the other way, i.e. (merge-pathnames ".lisp" <filename>)
since I would like to use nil (unspecified) instead of ".lisp". I want
to avoid doing string-search since it would likely be non-portable.
You can use make-pathname, specifying the type explicitly and
defaulting everything else from the original pathname.
> (make-pathname :type nil :defaults #P"/foo/bar.lisp")
#P"/foo/bar"
> (pathname-type *)
NIL
>
From: Thomas A. Russ
Subject: Re: changing the pathname type
Date:
Message-ID: <22381@venera.isi.edu>
Well, there's always:
(make-pathname :host (pathname-host old-pathname)
:directory (pathname-directory old-pathname)
...
:type nil)
--
Thomas A. Russ ···@isi.edu
USC/ISI, 4676 Admiralty Way, Marina del Rey, CA 90292 (310) 822-1511
In article <······················@monsun.si.no>, ········@monsun.si.no (Hallvard Tr{tteberg) writes:
|> I would like to change the filetype of a pathname (e.g. to nil
|> (unspecified) or .lisp)....
|> I cannot use (merge-pathnames <filename> ".lisp") since this
|> will only "change" the pathname-type if it is nil (unspecified)
(make-pathname :defaults <filename>
:type ".lisp")
(make-pathname :defaults <filename>
:type nil)
..................................................
Len Charest, Jr.
JPL Artificial Intelligence Group
·······@aig.jpl.nasa.gov