From: Michel T. <ta...@lp...> - 2025-04-02 18:45:41
|
This is something which works on Linux, sbcl: mkdir A; touch A/x A/y A/z then run the following (require :sb-posix) (handler-case (let ((dir-h (sb-posix:opendir "A")) elem) (loop when (setq elem (sb-posix:readdir dir-h)) do (print (sb-posix:dirent-name elem))) (sb-posix:closedir dir-h)) (sb-sys:memory-fault-error () nil)) produces: "x" "z" ".." "y" "." NIL In the program, A is the directory to examine, dir-h is a handle to it, elem is an element of the directory, containing a lot of information about each file, dirent-name selects the name. In the result "." corresponds to A et ".." to its parent. handler-case allows to ignore completely the memory fault error which occurs when the successive calls to readdir fall outside of the directory. Unfortunately the "when" above is not effective. Le 02/04/2025 à 12:32, Michel Talon a écrit : > For Unix one has to use opendir, readdir, closedir in succession. -- Michel Talon |