lispcommon-lispcclclozure-cl

Clozure Common Lisp - file-exists-p is undefined


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?


Solution

  • 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/"