BRL-CAD
Loading...
Searching...
No Matches
Bu_glob

Routines and structures for getting a list of entities that match a given pattern. More...

Files

file  glob.h
 

Data Structures

struct  bu_dirent
 
struct  bu_stat
 
struct  bu_glob_context
 

Typedefs

typedef struct bu_glob_context bu_glob_t
 

Functions

struct bu_glob_contextbu_glob_ctx_create (void)
 
void bu_glob_ctx_destroy (struct bu_glob_context *)
 
int bu_glob (const char *pattern, int flags, struct bu_glob_context *context)
 

Detailed Description

Routines and structures for getting a list of entities that match a given pattern.

The bu_glob API is a portable, callback-based glob implementation modelled on POSIX glob(3) and inspired by OpenBSD's glob.c. By supplying custom opendir/readdir/closedir/lstat/stat callbacks any hierarchical namespace (filesystem, BRL-CAD .g database, etc.) can be searched. The default callbacks use the system filesystem.

See also: src/librt/db_glob.c for the geometry-database backend (db_path_glob) which plugs into this API.

Typedef Documentation

◆ bu_glob_t

Definition at line 150 of file glob.h.

Function Documentation

◆ bu_glob_ctx_create()

struct bu_glob_context * bu_glob_ctx_create ( void  )

Create a globbing context

◆ bu_glob_ctx_destroy()

void bu_glob_ctx_destroy ( struct bu_glob_context )
extern

release any resources allocated during bu_glob(), including any returned paths

◆ bu_glob()

int bu_glob ( const char pattern,
int  flags,
struct bu_glob_context context 
)
extern

Match a pattern against a set of elements.

This interface is a somewhat simplified and abstracted version of UNIX glob matching, based loosely on the interface specified in POSIX.2. It supports user specified callback functions allowing callers to glob nearly any named storage structure. By default, globbing will map to the local filesystem.

Function takes an input pattern, a set of flags, and a globbing context from bu_glob_ctx_create().

Returns zero on success, non-zero on failure.

gl_pathc will contain the total number of paths matched. This will increment previous glob counts if GLOB_APPEND is specified.

gl_matchc will contain the number of matched paths for this invocation of bu_glob().

gl_pathv contains a list of matched paths.