Predefined File Search Paths

user:file_search_path/2 is undefined at startup, but all callers first try a number of default file search paths, almost as if user:file_search_path/2 had the following initial clauses. Therefore, to expand file search paths, you should not call user:file_search_path/2 directly, but instead call absolute_file_name/[2,3].

See ref-lps-flg for more info on the Prolog flag host_type.

The system properties SP_APP_DIR and SP_RT_DIR expand respectively to the absolute path of the directory that contains the executable and the directory that contains the SICStus runtime. The system property SP_TEMP_DIR expands to a directory suitable for storing temporary files, it is particularly useful with the open/4 option if_exists(generate_unique_name).

     %% file_search_path/2 (virtual) initial clauses
     file_search_path(library, '$SP_LIBRARY_DIR').
     file_search_path(library, Path) :-
     file_search_path(system, Platform) :-
             prolog_flag(host_type, Platform).
     file_search_path(application, '$SP_APP_DIR').
     file_search_path(runtime, '$SP_RT_DIR').
     file_search_path(temp, '$SP_TEMP_DIR').
     file_search_path(path, Path) :-
      %% enumerate all directories in $PATH

The only default expansion for the library file search path is the value of the system property SP_LIBRARY_DIR. However, you can add expansions for library by adding clauses to user:library_directory/1 (which is initially undefined). This feature is mainly for compatibility with earlier releases. It is better to add your own names for file search paths directly to user:file_search_path/2 and not extend the file search path library at all.

     :- multifile user:library_directory/1.

Send feedback on this subject.