Re: How to change directory/path in SBCL?



Harald Hanche-Olsen <hanche@xxxxxxxxxxxx> writes:

+ "keyboard" <xiewensheng@xxxxxxxxx>:

| When I load a lisp file using the true/full path name, many files
| which have relative path to that file cannot be loaded

The usual way to deal with this is to construct the full pathname of
the files you wish to load by using

(merge-pathnames relative-path *load-truename*)

as the pathname to load.

And CL usually maintains a different "current working directory" than
the underlying posix system (which may not even exist, for a given CL
implementation).

That is: *DEFAULT-PATHNAME-DEFAULTS*

So, the CL way of doing chdir(path);
is (setf *DEFAULT-PATHNAME-DEFAULTS* path)

A MERGE-PATHNAMES with this default path is done automatically by most
of the CL functions dealing with files.

Of course, if your implementation works on posix and provides a way to
use chdir(2), you might want to keep both synchronized.

(defun cd (path)
(setf *default-pathname-defaults* path)
#+(and clisp linux) (linux:|chdir| (namestring (truename path)))
#|and other implementation dependent insanities...|#)


--
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
.



Relevant Pages

  • Re: Simple Serialization for a hashtable
    ... package you are in and can expect BINDUMP to work correctly. ... need to do is ensure the environment is correct when you want to LOAD ... "Dumps OBJECT into as a FASL-file designated by PATHNAME." ...
    (comp.lang.lisp)
  • Re: How to change directory/path in SBCL?
    ... | When I load a lisp file using the true/full path name, ... | which have relative path to that file cannot be loaded ... the files you wish to load by using ... as the pathname to load. ...
    (comp.lang.lisp)
  • Re: How to change directory/path in SBCL?
    ... | When I load a lisp file using the true/full path name, ... | which have relative path to that file cannot be loaded ... the files you wish to load by using ... as the pathname to load. ...
    (comp.lang.lisp)
  • Re: [ANN] Ltk - The Lisp Toolkit
    ... of, if that does not work, the full pathname. ... > When I load ltk.lisp, it maybe works and the file is loaded. ... Then the test window should come up. ... Peter Herth ...
    (comp.lang.lisp)
  • Relative path & image
    ... is possible use relative path in access? ... Is posible don´t put a path to the picture ... in the image control? ... The Database will be move frecuntly and it will give error in the form load ...
    (comp.databases.ms-access)