YAZ  5.23.1
Macros | Typedefs | Functions
file_glob.h File Reference

File globbing (ala POSIX glob, but simpler) More...

#include <yaz/yconfig.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define YAZ_FILE_GLOB_FAIL_NOTEXIST   1
 

Typedefs

typedef struct glob_resyaz_glob_res_t
 file glob handle More...
 

Functions

int yaz_file_glob (const char *pattern, yaz_glob_res_t *res)
 perform glob More...
 
int yaz_file_glob2 (const char *pattern, yaz_glob_res_t *res, unsigned flags)
 perform glob (with flags) More...
 
void yaz_file_globfree (yaz_glob_res_t *res)
 release glob result More...
 
const char * yaz_file_glob_get_file (yaz_glob_res_t res, size_t idx)
 return resulting matching file More...
 
size_t yaz_file_glob_get_num (yaz_glob_res_t res)
 return number of matching files More...
 

Detailed Description

File globbing (ala POSIX glob, but simpler)

Definition in file file_glob.h.

Macro Definition Documentation

#define YAZ_FILE_GLOB_FAIL_NOTEXIST   1

Definition at line 43 of file file_glob.h.

Referenced by glob_r().

Typedef Documentation

typedef struct glob_res* yaz_glob_res_t

file glob handle

Definition at line 41 of file file_glob.h.

Function Documentation

int yaz_file_glob ( const char *  pattern,
yaz_glob_res_t res 
)

perform glob

Parameters
patternglob pattern file spec
resreturned glob result
Return values
0OK
-1ERROR

Definition at line 141 of file file_glob.c.

References yaz_file_glob2().

int yaz_file_glob2 ( const char *  pattern,
yaz_glob_res_t res,
unsigned  flags 
)

perform glob (with flags)

Parameters
patternglob pattern file spec
resreturned glob result
flagsYAZ_FILE_GLOB_.. flags
Return values
0OK
-1ERROR

Definition at line 146 of file file_glob.c.

References glob_r(), nmem_create(), nmem_malloc(), and sort_them().

Referenced by config_include_src(), and yaz_file_glob().

const char* yaz_file_glob_get_file ( yaz_glob_res_t  res,
size_t  idx 
)

return resulting matching file

Parameters
resglob result
idxindex 0=first, .. N-1 (where N is yaz_file_glob_get_num)
Returns
file name or NULL if idx is out-of-range

Definition at line 173 of file file_glob.c.

References glob_res::entries, res_entry::file, and res_entry::next.

Referenced by config_include_src().

size_t yaz_file_glob_get_num ( yaz_glob_res_t  res)

return number of matching files

Parameters
resglob result
Returns
number of files

Definition at line 186 of file file_glob.c.

References glob_res::number_of_entries.

void yaz_file_globfree ( yaz_glob_res_t res)

release glob result

Parameters
respointer to glob result

A value of *res == NULL is allowed. If *res != NULL, then res is set to NULL

Definition at line 163 of file file_glob.c.

References nmem_destroy().

Referenced by config_include_src().