The idea is rather simple. Files may be specified as Alias(Relative). The typical example is library(lists). The Alias is library
, the relative path lists
. The aliases are defined using user:file_search_path(Alias, Dir)
. This should return candidate directories to search for files with the alias Alias. Dir is either a concrete directory or another Alias(Relative) term.
app_data
is not for your program. These (and a couple more) provide search paths to find application data, etc. according to the XDG desktop file organization standards.
To make a relocatable application myapp
, it is common practice to have the main file setup a file search rule for myapp
, pointing at the root directory of the application. You can than find all files as myapp(Relative). You typically use either prolog_load_context/2 to initialise the myapp alias or source_file/2 using a unique predicate in the initial load file:
myapp_version(1.0).
user:file_search_path(myapp, Dir) :-
source_file(myapp_version(_), File),
file_directory_name(File, Dir).
[I like these doc links! thanks @EricGT!