Shell-style pathname pattern expansion

Author(s): Manuel Hermenegildo (original file_find.pl), Jose F. Morales.

This module provides file searching predicates to locate pathnames matching a globbing pattern (shell wildcard expansion).

Usage and interface

Documentation on exports

REGTYPE

Usage:glob_pattern(Pattern)

Pattern is a pathname pattern whose components may contain shell-style wildcards.

    PREDICATE
    glob(Directory,Pattern,FileList)

    Search the list of pathnames FileList matching the specified pathname pattern Pattern. If Pattern is an absolute path, Directory is ignored. Otherwise, all matches are relative to Directory. If Directory does not exist FileList is empty. The shortest version glob/2 can be used when Directory is '.' (the current directory).

    For example, glob/2 and glob/3 will give the following results in a typical Unix installation:

    ?- use_module(library(glob)).
    
    yes
    ?- cd('/bin').
    
    yes
    ?- glob('e*', F).
    
    F = [expr,ed,echo] ? 
    
    yes
    ?- glob('/', 'bin/e*', F).
    
    F = ['bin/expr','bin/ed','bin/echo'] ? 
    
    yes
    ?- glob('/tmp', '../bin/e*', F).
    
    F = ['../bin/expr','../bin/ed','../bin/echo'] ? 
    
    yes
    ?- cd('/tmp').
    
    yes
    ?- glob('/bin/e*', F).
    
    F = ['/bin/expr','/bin/ed','/bin/echo'] ? 
    
    yes
    

    Usage:glob(Directory,Pattern,FileList)

    FileList is the list of pathnames matching the specified pathname pattern Pattern, relative to Directory.

    • Call and exit should be compatible with:
      (pathnames:pathname/1)Directory is a pathname (encoded as an atom)
      (pathnames:pathname/1)Pattern is a pathname (encoded as an atom)
      (basic_props:list/2)FileList is a list of pathnames.

    PREDICATE

    Usage:glob(Pattern,FileList)

    Like glob/3, relative to the current directory (equivalent to glob('.', Pattern, FileList))

    • Call and exit should be compatible with:
      (pathnames:pathname/1)Pattern is a pathname (encoded as an atom)
      (basic_props:list/2)FileList is a list of pathnames.