Next: , Previous: , Up: Files   [Contents][Index]


5.17.4 Directories

You can open and read directories similar to files. Reading gives you one directory entry at a time; you can match that to a filename (with wildcards).

open-dir       c-addr u – wdirid wior        gforth       “open-dir”

Open the directory specified by c-addr, u and return dir-id for futher access to it.

read-dir       c-addr u1 wdirid – u2 flag wior        gforth       “read-dir”

Attempt to read the next entry from the directory specified by dir-id to the buffer of length u1 at address c-addr. If the attempt fails because there is no more entries, ior=0, flag=0, u2=0, and the buffer is unmodified. If the attempt to read the next entry fails because of any other reason, return ior<>0. If the attempt succeeds, store file name to the buffer at c-addr and return ior=0, flag=true and u2 equal to the size of the file name. If the length of the file name is greater than u1, store first u1 characters from file name into the buffer and indicate "name too long" with ior, flag=true, and u2=u1.

close-dir       wdirid – wior        gforth       “close-dir”

Close the directory specified by dir-id.

filename-match       c-addr1 u1 c-addr2 u2 – flag        gforth       “match-file”
get-dir       c-addr1 u1 – c-addr2 u2        gforth       “get-dir”

Store the current directory in the buffer specified by c-addr1, u1. If the buffer size is not sufficient, return 0 0

set-dir       c-addr u – wior        gforth       “set-dir”

Change the current directory to c-addr, u. Return an error if this is not possible

=mkdir       c-addr u wmode – wior        gforth       “equals-mkdir”

Create directory c-addr u with mode wmode.

mkdir-parents       c-addr u mode – ior         unknown       “mkdir-parents”

create the directory c-addr u and all its parents with mode mode (modified by umask)


Next: , Previous: , Up: Files   [Contents][Index]