Listing the contents of a directory (Windows 7)

103 views Asked by At

Using Kawa 1.14.

I have tried opening the directory as a file (because file-exists? reports #t), and using read-line to read the "contents", but it does not work. I get an "Access denied" error.

2

There are 2 answers

0
Vince Refiti On BEST ANSWER

Looking through the source, I found kawa\lib\files.scm, which defines directory-files.

So, it is just a matter of:

(require <kawa.lib.files>)
(directory-files path)
0
C. K. Young On

At the Java level, there are two ways to list directories. You can use File.list or File.listFiles, or you can use Files.newDirectoryStream.

At the Kawa level, having briefly grepped through the source, it doesn't seem to use any of those interfaces. So it doesn't look like there's a built-in way to list directories in Kawa. You would need to use Kawa's Java method invocation features to invoke one of the above interfaces.