tpath.h File Reference

File Path utilities. More...

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

Go to the source code of this file.

Functions

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

Detailed Description

File Path utilities.

Definition in file tpath.h.


Function Documentation

int yaz_fclose ( FILE *  f  ) 

closes file

Parameters:
f FILE handle
Return values:
-1 on failure
0 on success

Definition at line 39 of file tpath.c.

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

get next path component in filepath

Parameters:
path_p pointer to path (updated to "next" entry if any)
comp upon pointer to component (if component is found)
Return values:
0 no component found (and no more componennts)
>0 length 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 45 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)
path the path (dir1:dir2,..) - ala Unix
base can be added to relative paths (NULL for no append)
fullpath the full path to filename (if succesful)

Returns 0/NULL if no fname could be found in path; pointer to fullpath if fname could be found. We assume fullpath is 1024 bytes in length!

Definition at line 75 of file tpath.c.

References yaz_filepath_comp().

Referenced by 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)
mode mode as in fopen(3)
path the path (dir1:dir2,..) - ala Unix
base can be added to relative paths (NULL for no append)

Returns 0/NULL if no fname could be found in path; FILE pointer if fname could be found.

Definition at line 114 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:
path path to checked
Return values:
1 path is absolute
0 path is relative

Definition at line 124 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)
mode mode as in fopen(3)
path the path (dir1:dir2,..) - ala Unix

Returns 0/NULL if no fname could be found in path; FILE pointer if fname could be found.

Definition at line 34 of file tpath.c.

References yaz_fopen().

Generated on Tue Aug 17 13:13:20 2010 for YAZ by  doxygen 1.6.3