13.4.3 Declaring resources
- resource(:Name, +FileSpec)
- resource(:Name, +FileSpec, +Options)
- These predicates are defined as dynamic predicates in the module
user
. Clauses for them may be defined in any module, including the user module. Name is the name of the resource (an atom). A resource name may contain any character, except for $ and :, which are reserved for internal usage by the resource library. FileSpec is a file specification that may exploit file_search_path/2 (see absolute_file_name/2).Often, resources are defined as unit clauses (facts), but the definition of this predicate also allows for rules. For proper generation of the saved state, it must be possible to enumerate the available resources by calling this predicate with all its arguments unbound.
If FileSpec points at a directory, the content of the directory is recursively added below Name. If FileSpec a term of the form
Alias(Name)
, all directories that match this specification are enumerated and their content is added to the resource database. If an file appears in multiple results of this search path only the first file is added. Note that this is consistent with the normal behaviour where absolute_file_name/3 returns the first match. The Options can be used to control what is saved from a directory.- include(+Patterns)
- Only include a file from a directory if it matches at least one of the members of Patterns.
- exclude(+Patterns)
- Excludes a file from a directory if it matches at least one of the members of Patterns.