YAZ  5.23.1
Functions
tpath.c File Reference

File Path utilities. More...

#include <stdio.h>
#include <string.h>
#include <yaz/tpath.h>
#include <yaz/log.h>

Go to the source code of this file.

Functions

FILE * yaz_path_fopen (const char *path, const char *name, const char *mode)
 opens first file in path in path More...
 
int yaz_fclose (FILE *f)
 closes file More...
 
size_t yaz_filepath_comp (const char **path_p, const char **comp)
 get next path component in filepath More...
 
char * yaz_filepath_resolve (const char *fname, const char *path, const char *base, char *fullpath)
 resolve file on path More...
 
FILE * yaz_fopen (const char *path, const char *fname, const char *mode, const char *base)
 opens first file in path in path More...
 
int yaz_is_abspath (const char *p)
 checks whether path is absolute More...
 

Detailed Description

File Path utilities.

Definition in file tpath.c.

Function Documentation

int yaz_fclose ( FILE *  f)

closes file

Parameters
fFILE handle
Return values
-1on failure
0on success

Definition at line 38 of file tpath.c.

size_t yaz_filepath_comp ( const char **  path_p,
const char **  comp 
)

get next path component in filepath

Parameters
path_ppointer to path (updated to "next" entry if any)
compupon pointer to component (if component is found)
Return values
0no component found (and no more componennts)
>0length of component (length of *comp)

A filepath has components separted by colon. For example /usr/lib/modules:c:/my:/:lib which has these components "/usr/lib/modules", "c:/my", "/", "lib"

Definition at line 44 of file tpath.c.

Referenced by yaz_filepath_resolve().

char* yaz_filepath_resolve ( const char *  fname,
const char *  path,
const char *  base,
char *  fullpath 
)

resolve file on path

Parameters
fname"short" filename (without path)
paththe path (dir1:dir2,..) - ala Unix
basecan be added to relative paths (NULL for no append)
fullpaththe full path to filename (if successful)
Returns
fullpath or NULL if file could not be found

Be sure to allocate at least 1024 bytes for fullpath

Definition at line 74 of file tpath.c.

References yaz_filepath_comp().

Referenced by construct_xslt(), xml_config_read(), and yaz_fopen().

FILE* yaz_fopen ( const char *  path,
const char *  fname,
const char *  mode,
const char *  base 
)

opens first file in path in path

Parameters
fname"short" filename (without path)
modemode as in fopen(3)
paththe path (dir1:dir2,..) - ala Unix
basecan be added to relative paths (NULL for no append)
Returns
FILE pointer if fname could be found; NULL otherwise

Definition at line 117 of file tpath.c.

References yaz_filepath_resolve().

Referenced by yaz_path_fopen().

int yaz_is_abspath ( const char *  path)

checks whether path is absolute

Parameters
pathpath to checked
Return values
1path is absolute
0path is relative

Definition at line 127 of file tpath.c.

Referenced by conf_dir_path().

FILE* yaz_path_fopen ( const char *  path,
const char *  fname,
const char *  mode 
)

opens first file in path in path

Parameters
fname"short" filename (without path)
modemode as in fopen(3)
paththe path (dir1:dir2,..) - ala Unix
Returns
FILE pointer if fname could be found; NULL otherwise

Definition at line 33 of file tpath.c.

References yaz_fopen().