[eclipse-devel] Re : Re : 'built-in' config file not found by eclipse
Iban HATCHONDO
hatchond at yahoo.fr
Tue Apr 27 12:10:31 UTC 2010
This has been committed in the CVS tree
Best,
Iban.
----- Message d'origine ----
De : Iban HATCHONDO <hatchond at yahoo.fr>
À : eclipse-devel at common-lisp.net
Envoyé le : Lun 26 avril 2010, 12 h 43 min 08 s
Objet : [eclipse-devel] Re : 'built-in' config file not found by eclipse
Well, you're right, I haven't paid attention that SBCL returns a valid pathname when probing a file with a pathname for a directory that is in reality a file.
I would propose the following (after reading the interesting point CL-FAD)
(defun file-exists-p (filename)
"Returns true if the given filename is an existing file and not a directory."
(and #+clisp (not (probe-directory (make-pathname :directory filename)))
#-clisp (let ((pathname (probe-file (make-pathname :directory filename))))
;; When NIL is returned by probe-file, it indicates that NO
;; directory exists under this filename.
;; But when a valid pathname is returned, it does not
;; necessarily indicate that it is a directory.
;; In this case, one needs to check if the returned pathname
;; has a type or a name, what a directory pathname doesn't
;; have.
;; This last case concerns systems like SBCL, while the former
;; case corresponds at least to CMUCL.
(if pathname
(let ((name (pathname-name pathname))
(type (pathname-type pathname)))
(or (and type (not (eql type :unspecific)))
(and name (not (eql type :unspecific)))))
t))
(probe-file filename)))
It seems be the proper way to deal with systems that have equivalent behavior to SBCL?
Best,
Iban.
----- Message d'origine ----
De : david thompson <thompdump at gmail.com>
À : eclipse-devel at common-lisp.net
Envoyé le : Sam 24 avril 2010, 21 h 49 min 14 s
Objet : [eclipse-devel] 'built-in' config file not found by eclipse
I tried out the most recent CVS version. The problem with the
preexisting ~/.eclipse directory seems to be resolved. However, now
eclipse doesn't find the 'built-in' config file with SBCL:
EWMI> (eclipse::file-exists-p (eclipse-path "eclipserc"))
NIL
EWMI> (eclipse-path "eclipserc")
"/home/thomp/downloads/window-managers/eclipse-cvs/eclipse/eclipserc"
but the file is present:
d630:eclipse# ls -al
/home/thomp/downloads/window-managers/eclipse-cvs/eclipse/eclipserc
-rw-r--r-- 1 root root 2834 2003-08-28 07:51
/home/thomp/downloads/window-managers/eclipse-cvs/eclipse/eclipserc
I think the issue might be with FILE-EXISTS-P - in SBCL, it looks like
a nonsensical path is generated:
EWMI> (probe-file (eclipse-path "eclipserc"))
#P"/home/thomp/downloads/window-managers/eclipse-cvs/eclipse/eclipserc"
EWMI> (not (probe-file (make-pathname :directory (eclipse-path "eclipserc"))))
NIL
EWMI> (make-pathname :directory (eclipse-path "eclipserc"))
#P"//home/thomp/downloads/window-managers/eclipse-cvs/eclipse/eclipserc/"
CL-FAD has some 'directory-p and file-p'-ish functionality that is
intended to be portable across implementations. It might be a useful
starting point. On the other hand, I also vaguely remember some weird
behavior (e.g., I think the CL-FAD DIRECTORY-EXISTS-P function returns
a true value when fed an empty string).
For what it's worth, this (in global.lisp) seems to work with SBCL with linux:
(defun directory-p (pathname)
(let ((close?
(ignore-errors
(sb-posix:opendir pathname))))
(if close? (sb-posix:closedir close?))))
(defun file-exists-p (filename)
"Returns true if the given filename is an existing file and not a directory."
(and
#+sbcl (not (directory-p filename))
#+clisp (not (probe-directory (make-pathname :directory filename)))
#-(or :clisp :sbcl) (not (probe-file (make-pathname :directory filename)))
(probe-file filename)))
_______________________________________________
eclipse-devel site list
eclipse-devel at common-lisp.net
http://common-lisp.net/mailman/listinfo/eclipse-devel
_______________________________________________
eclipse-devel site list
eclipse-devel at common-lisp.net
http://common-lisp.net/mailman/listinfo/eclipse-devel
More information about the eclipse-devel
mailing list