As of SWI-Prolog 7.7.13, resources that are compiled into the program can be accessed using the normal file handling predicates. Currently the following predicates transparently handle resources as read-only files:
In addition, open_shared_object/3, underlying use_foreign_library/1 handles shared objects or DLLs by copying them to a temporary file and opening this file. If the OS allows for it, the copied file is deleted immediately, otherwise it is deleted on program termination.
With the ability to open resources as if they were files we can use them for many tasks without changing the source code as required when using open_resource/2. Below we describe a typical scenario.
icon(file)
.
res://app/icon/
file.
resource(app/icon, icon(.)).
:- asserta(user:file_search_path(icon, 'res://app/icon').