[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: how I can check whether a directory exists with scheme



In the meantime I found a solution for a directory
check:

(define is_dir
(lambda (path)
    (if (access? path F_OK)
        (string=? (stat:type(lstat path)) "directory")
        #f
        )
    )
 )

May it is not the most elegant, however it
seems working.

best regards
Karsten

Karsten Einwich wrote:
Hallo,
I want to parse a root directory for
other subdirectories.

Therefore I use the code like this
....
(do
( (entry (readdir dir) (readdir dir)))
( (eof-object? entry) )
(let ((sub_dir (opendir (string-append root_path "/" entry)))) (if (sub_dir) ...



This code will fail with a System Error if entry a file name instead a directory.

opendir seems not deliver a #f like described in
the SCM-manual by Aubrey Jaffer.

Is there an other solution to check whether a string
corresponds to an existing directory ?

Rhanks a lot
Karsten