2

I get a "Undefined function FILE-EXISTS-P called with arguments ..." error when calling (file-exists-p "somepath") in Clozure Common Lisp but everywhere I look it appears that this function should be available. I even see it when using M-x apropos.

I'm using LispBox for Windows.

Does anyone have an idea of what might be wrong or maybe suggest a process by which I can try to figure it out?

Renzo
  • 26,848
  • 5
  • 49
  • 61
Denis
  • 145
  • 1
  • 8
  • 2
    `M-x apropos` shows you Emacs Lisp functions, not Common Lisp functions (which you'd find with `(apropos "...")` in the REPL or the equivalent slime commands). Also you should consider using [Portacle](https://portacle.github.io/) instead of LispBox (which hasn't been updated in years). – jkiiski Dec 17 '18 at 05:01
  • 1
    FILE-EXISTS-P is not a standard Common Lisp function or a Clozure Common Lisp specific function. You can use the standard PROBE-FILE function (see the [manual](http://www.lispworks.com/documentation/HyperSpec/Body/f_probe_.htm#probe-file)) to check if a file exists. – Renzo Dec 17 '18 at 06:17
  • Thank you! I'll consider Portacle. I see now how I was looking in the wrong place - PROBE-FILE works. @Renzo - I think your comment is the better answer, but because its a comment I can't mark it as such. – Denis Dec 17 '18 at 06:27

1 Answers1

7

FILE-EXISTS-P is not a standard Common Lisp function or a Clozure Common Lisp specific function.

Instead, you can use the standard PROBE-FILE function (see the manual) to check if a file exists:

CL-USER> (probe-file "not-existant-file.lisp")
NIL
CL-USER> (probe-file "/Users/myname/temp.lisp")
#P"/Users/myname/temp.lisp"

Note that the in the standard is undefined the result of applying the function to a directory, while the CCL implementation (at least on some systems) checks correctly also if a directory exists:

CL-USER> (probe-file "/Users/myname/")
#P"/Users/myname/"
Renzo
  • 26,848
  • 5
  • 49
  • 61
  • There's also `uiop:probe-file*`. It works for files and directories, and since uiop is part of asdf, the chances that it is available are pretty good. – Pascal May 03 '19 at 09:35