Introduction -- library(directory)

For the most part, Prolog programs have little need to examine directories or to inquire about file properties. However, the need does occasionally arise. For example, an expert-system shell might offer the option of either loading a single file into its knowledge base, or of loading all the files in a directory having a particular extension. The Quintus Prolog library file library(directory) provides the tools you need to do this. For example, we might define

     kb_load(File) :-
         (  directory_property(File, searchable) ->
         ;  file_property(File, readable) ->
         ;  format(user_error, '~N! cannot read ~w.~n', [File]),

The routines in this package were designed to be a complete toolkit for safely wandering around a UNIX-like file system. Although there are quite a few of them, they do actually fit together in a coherent group. For information on operations relating to individual files rather than to directories, see library(files) (lib-ofi).

The following principles have been observed: