• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

14.4 Using program resources
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Deploying applications
        • Using program resources
          • Resources as files
          • Access resources using open_resource
          • Declaring resources
            • resource/2
            • resource/3
          • Managing resource files
    • Packages

14.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.

ClioPatria (version V3.1.1-51-ga0b30a5)