Respectech
Respectech

Reputation: 454

How do you get a directory listing in Red/System?

I've tried to include Kaj de Vos's excellent C library binding available in ANSI.reds, but still cannot find a way to read a directory listing.

I thought that maybe if I could read the . file in binary, I could parse it, but I just get back a NULL pointer:

sizedir: 0
dir: read-file-binary "my-dir/." :sizedir
print-line dir

If I try reading it as a text file, I get a:

*** Runtime Error 1: access violation
*** at: 0040152Eh

Any ideas?

Upvotes: 1

Views: 168

Answers (1)

Kaj de Vos
Kaj de Vos

Reputation: 31

A piece of additional code and definitions needs to be written to read the directory structure and interpret it. It's tricky, because it's partly system dependent, so it goes beyond the ANSI part of my C library binding. Also, to achieve a higher abstraction level on the way to the directory functions in REBOL, you'd have to think about extra data structures that are not native to Red/System.

Upvotes: 3

Related Questions