libfossil
fsl_pathfinder Struct Reference

The "Path Finder" class is a utility class for searching the filesystem for files matching a set of common prefixes and/or suffixes (i.e. More...

#include "fossil-util.h"

Data Fields

fsl_buffer buf
 Used to build up a path string during fsl_pathfinder_search(), and holds the result of a successful search. More...
 
fsl_list dirs
 Holds the list of search directories. More...
 
fsl_list ext
 Holds the list of search extensions. More...
 

Detailed Description

The "Path Finder" class is a utility class for searching the filesystem for files matching a set of common prefixes and/or suffixes (i.e.

directories and file extensions).

Example usage:

int rc;
char const * found = NULL;
rc = fsl_pathfinder_ext_add( &pf, ".doc" );
if(rc) { ...error... }
// The following error checks are elided for readability:
rc = fsl_pathfinder_ext_add( &pf, ".txt" );
rc = fsl_pathfinder_ext_add( &pf, ".wri" );
rc = fsl_pathfinder_dir_add( &pf, "." );
rc = fsl_pathfinder_dir_add( &pf, "/my/doc/dir" );
rc = fsl_pathfinder_dir_add( &pf, "/other/doc/dir" );
rc = fsl_pathfinder_search( &pf, "MyDoc", &found, NULL);
if(0==rc){ assert(NULL!=found); }
// Eventually clean up:
See also
fsl_pathfinder_dir_add()
fsl_pathfinder_ext_add()
fsl_pathfinder_clear()
fsl_pathfinder_search()

Definition at line 3262 of file fossil-util.h.

Field Documentation

fsl_buffer fsl_pathfinder::buf

Used to build up a path string during fsl_pathfinder_search(), and holds the result of a successful search.

We use a buffer, as opposed to a simple string, because (A) it simplifies the search implementation and (B) reduces allocations (it gets reused for each search).

Definition at line 3280 of file fossil-util.h.

fsl_list fsl_pathfinder::dirs

Holds the list of search directories.

Each entry is a (char *) owned by this object.

Definition at line 3272 of file fossil-util.h.

fsl_list fsl_pathfinder::ext

Holds the list of search extensions.

Each entry is a (char *) owned by this object.

Definition at line 3267 of file fossil-util.h.


The documentation for this struct was generated from the following file: