Frequently Used File Specifications

Frequently used file_search_path/2 facts are best defined using the initialization file prolog.ini , which is consulted at startup time by the Development System. Therefore, with reference to the examples from ref-fdi-fsp-def, clauses like one following should be placed in the prolog.ini file so that they are automatically available to user programs after startup:

     :- multifile file_search_path/2.
     :- dynamic file_search_path/2.
     file_search_path(home, '/usr/jackson').
     file_search_path(qp_directory, home('prolog/qp')).
     file_search_path(demo, 'etc/demo').
     

If it is necessary to avoid multiple definitions of the same fact, this would be useful, for example, when restoring a saved state saved by save_program/1 at which time the prolog.ini file is consulted again, a predicate such as add_my_search_path/2 can be defined in the prolog.ini file.

     add_my_search_path(Name, FileSpec) :-
         file_search_path(Name, FileSpec),
         !.
     add_my_search_path(Name, FileSpec) :-
         assert(file_search_path(Name, FileSpec)).
     

This predicate only asserts a clause into the database if it is not already defined. Then, using goals of the following form avoids multiple definitions:

     :- add_my_search_path(home, '/usr/jackson').
     :- add_my_search_path(demo, 'etc/demo').
     :- add_my_search_path(qp_directory, home('prolog/qp')).