[id] = OpenDirectory(id, dir$[, table])
dir$
and assigns the
specified id
to it. If you pass Nil in id
, OpenDirectory()
will
automatically choose an identifier and return it. The directory can then
subsequently be examined by using the NextDirectoryEntry() function
which gives you low-level access to the directory which is especially
useful for large directories or if you need additional information
like sizes/attributes for the individual directory entries. You can get
these very fast using a loop as presented in the example below.
Starting with Hollywood 6.0 this function accepts an optional table argument which can be used to pass additional parameters. The following table elements are currently recognized:
Adapter:
UserTags:
You should call CloseDirectory() as soon as you are finished with the directory. This ensures that the directory does not stay locked by the file system longer than needed.
This command is also available from the preprocessor: Use @DIRECTORY to link whole directories to your applet or executable.
OpenDirectory(1, "Data") e = NextDirectoryEntry(1) While e <> Nil NPrint(IIf(e.type = #DOSTYPE_FILE, "File:", "Directory:"), e.name) e = NextDirectoryEntry(1) Wend CloseDirectory(1)The code above opens directory "Data" and prints all files and directories present in that directory.