• Re: Q: How can i check, if a file exists with SBCL ?

    From Lieven Marchand@21:1/5 to All on Sat Dec 17 18:01:21 2022
    There is a standard function PROBE-FILE that checks for the existence of
    files.

    --
    Laat hulle almal sterf. Ek is tevrede om die wêreld te sien brand en die vallende
    konings te spot. Ek en my aasdier sal loop op die as van die verwoeste aarde.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jens Kallup@21:1/5 to All on Sat Dec 17 17:32:41 2022
    Here the code, that result me always the format message:

    (defvar *ex*)
    (handler-case
    (progn
    (setq *ex* (open "aquicklisp" :if-exists :error))
    (print "QuickLisp missing, try to install ..."))
    (error (c)
    (progn
    (format t "Information: QuickLisp exists.~%")
    (exit))))

    --
    Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft. www.avast.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to Jens Kallup on Sat Dec 17 19:25:20 2022
    On Sat, 17 Dec 2022 17:32:41 +0100
    Jens Kallup <kallup-dev@web.de> wrote:
    Here the code, that result me always the format message:

    (defvar *ex*)
    (handler-case
    (progn
    (setq *ex* (open "aquicklisp" :if-exists :error))
    (print "QuickLisp missing, try to install ..."))
    (error (c)
    (progn
    (format t "Information: QuickLisp exists.~%")
    (exit))))

    CLHS says on OPEN :
    :if-exists

    if-exists specifies the action to be taken if direction is :output or :io
    and a file of the name filespec already exists. If direction is :input,
    not supplied, or :probe, if-exists is ignored.

    You may get a more informative error message if you just do
    (setq *ex* (open "aquicklisp" :if-exists :error))

    Also exit is not standard Common Lisp. It is helpful if you mention it when you use constructs which are specific to some implementation.

    --
    vlaho.ninja/prog

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jens Kallup@21:1/5 to All on Sat Dec 17 21:32:23 2022
    Am 17.12.2022 um 20:25 schrieb Spiros Bousbouras:
    Also exit is not standard Common Lisp. It is helpful if you mention it when you use constructs which are specific to some implementation.

    I have the code below, but the quickstart line produce error:
    I have remove all components that was installed from the install setup
    of quicklisp.

    (handler-case (progn
    (with-open-file (stream "./quicklisp/"
    :direction :input
    :if-does-not-exist :error))
    (print "111"))
    (error (c) (progn
    (format T "QuickLisp missing, try to install ...~%")
    (load "quicklisp.lisp")
    (quicklisp-quickstart:install) ; <-- here
    (print "222")
    )))


    E:\SBCL\1>sbcl --script test1.lisp

    Unhandled SB-C::INPUT-ERROR-IN-LOAD in thread

    #<SB-THREAD:THREAD "main thread" RUNNING {1001DD0003}>:
    READ error during LOAD:

    Package QUICKLISP-QUICKSTART does not exist.

    Line: 20, Column: 33, File-Position: 575

    Stream: #<SB-SYS:FD-STREAM for "file E:\\SBCL\\1\\test1.lisp"
    {1001DC0E53}>

    Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001DD0003}>
    0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SB-C::INPUT-ERROR-IN-LOAD
    {1001DC7083}> #<unused argument> :QUIT T)
    1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SB-C::INPUT-ERROR-IN-
    LOAD {1001DC7083}>)
    2: (INVOKE-DEBUGGER #<SB-C::INPUT-ERROR-IN-LOAD {1001DC7083}>)
    3: (ERROR #<SB-C::INPUT-ERROR-IN-LOAD {1001DC7083}>)
    4:
    (SB-C:COMPILER-ERROR SB-C::INPUT-ERROR-IN-LOAD :CONDITION #<SB-
    INT:SIMPLE-READER-PACKAGE-ERROR "Package ~A does not exist."
    {1001DC7023}> :STREAM #<SB-SYS:FD-STREAM for "file E:\\SBCL
    \\1\\test1.lisp" {1001DC0E53}>)
    5: (SB-C::%DO-FORMS-FROM-INFO #<FUNCTION (LAMBDA (SB-KERNEL:FORM &KEY
    :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE
    {1001DC61CB}> #<SB-C::SOURCE-INFO {1001DC6183}> SB-C::INPUT-ERROR-
    IN-LOAD)
    6: (SB-INT:LOAD-AS-SOURCE #<SB-SYS:FD-STREAM for "file E:\\SBCL
    \\1\\test1.lisp" {1001DC0E53}> :VERBOSE NIL :PRINT NIL :CONTEXT
    "loading")
    7: ((LABELS SB-FASL::LOAD-STREAM-1 :IN LOAD) #<SB-SYS:FD-STREAM for
    "file E:\\SBCL\\1\\test1.lisp" {1001DC0E53}> NIL)
    8: (SB-FASL::CALL-WITH-LOAD-BINDINGS #<FUNCTION (LABELS SB-FASL::LOAD-
    STREAM-1 :IN LOAD) {5FF3BB}> #<SB-SYS:FD-STREAM for "file E:\\SBCL
    \\1\\test1.lisp" {1001DC0E53}> NIL #<SB-SYS:FD-STREAM for "file
    E:\\SBCL\\1\\test1.lisp" {1001DC0E53}>)
    9: (LOAD #<SB-SYS:FD-STREAM
    for "file E:\\SBCL\\1\\test1.lisp" {1001DC0E53}> :VERBOSE NIL :PRINT
    NIL :IF-DOES-NOT-EXIST :ERROR :EXTERNAL-FORMAT :DEFAULT)
    10: ((FLET SB-IMPL::LOAD-SCRIPT :IN SB-IMPL::PROCESS-SCRIPT) #<SB-
    SYS:FD-STREAM for "file E:\\SBCL\\1\\test1.lisp" {1001DC0E53}>)
    11: ((FLET SB-UNIX::BODY :IN SB-IMPL::PROCESS-SCRIPT))
    12: ((FLET "WITHOUT-INTERRUPTS-BODY-11" :IN SB-IMPL::PROCESS-SCRIPT))
    13: (SB-IMPL::PROCESS-SCRIPT "test1.lisp")
    14: (SB-IMPL::TOPLEVEL-INIT)
    15: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP))
    16: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-IMPL::START-LISP))
    17: (SB-IMPL::%START-LISP)
    18: ("foreign function: #x140034DE5")
    19: ("foreign function: #x1400051E0")


    --
    Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft. www.avast.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Russ@21:1/5 to Jens Kallup on Mon Dec 19 10:06:58 2022
    On Saturday, December 17, 2022 at 12:32:29 PM UTC-8, Jens Kallup wrote:
    Am 17.12.2022 um 20:25 schrieb Spiros Bousbouras:
    Also exit is not standard Common Lisp. It is helpful if you mention it when you use constructs which are specific to some implementation.
    I have the code below, but the quickstart line produce error:
    I have remove all components that was installed from the install setup
    of quicklisp.

    (handler-case (progn
    (with-open-file (stream "./quicklisp/"
    :direction :input
    :if-does-not-exist :error))
    (print "111"))
    (error (c) (progn
    (format T "QuickLisp missing, try to install ...~%")
    (load "quicklisp.lisp")
    (quicklisp-quickstart:install) ; <-- here
    (print "222")
    )))

    Perhaps try
    (load "quicklisp.lisp" :verbose t :print t)
    to get more information about the loading process?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)