libexplain  1.4.D001
Functions
libexplain/path_search.c File Reference
#include <libexplain/ac/errno.h>
#include <libexplain/ac/stdio.h>
#include <libexplain/ac/stdlib.h>
#include <libexplain/ac/string.h>
#include <libexplain/ac/sys/stat.h>
#include <libexplain/path_search.h>
#include <libexplain/program_name.h>
#include <libexplain/buffer/eexist.h>
#include <libexplain/buffer/software_error.h>

Go to the source code of this file.

Functions

static int direxists (const char *pathname)
int explain_path_search (char *pathname, size_t pathname_size, const char *dir, const char *prefix, int try_tmpdir)
static void paths_push (const char **paths, size_t *paths_count, const char *path)
int explain_path_search_explanation (explain_string_buffer_t *sb, int errnum, const char *dir, int try_tmpdir)

Function Documentation

static int direxists ( const char *  pathname) [static]

Definition at line 41 of file path_search.c.

int explain_path_search ( char *  tmpl,
size_t  tmpl_len,
const char *  dir,
const char *  pfx,
int  try_tmpdir 
)

The explain_path_search function may be used to determine where to place temporary files.

The following are searched for, in order 1. Uses the first of $TMPDIR (if try_tmpdir) 2. the dir argument 3. P_tmpdir 4. /tmp

Copies into tmpl a template suitable for use with mkstemp(), et al.

Parameters:
tmplWhere to write the pathname template.
tmpl_lenThe maximum available size of the pathname template.
dirThe preferred temporary directory.
pfxfile name prefix, must not contail any slash (/) characters
try_tmpdiruse the $TMPDIR environment variable, if set and exists.
Returns:
0 on success,or -1 on error (with errno set).

EINVAL The supplied buffer for tmpl is too small. ENOENT None of the directories in the search path exist.

Definition at line 59 of file path_search.c.

int explain_path_search_explanation ( struct explain_string_buffer_t sb,
int  errnum,
const char *  dir,
int  try_tmpdir 
)

The explain_path_search_explanation function may be used to

Parameters:
sbbuffer to write into
errnumthe error to be explained
dirdirectory to search, as passwd to path_search
try_tmpdiruse the $TMPDIR environment variable, if set and exists.
Returns:
0 if printed something, -1 if couldn't explain error

Definition at line 179 of file path_search.c.

static void paths_push ( const char **  paths,
size_t *  paths_count,
const char *  path 
) [static]

Definition at line 157 of file path_search.c.