libexplain  1.4.D001
Functions
libexplain/buffer/get_current_directory.c File Reference
#include <libexplain/ac/assert.h>
#include <libexplain/ac/dirent.h>
#include <libexplain/ac/errno.h>
#include <libexplain/ac/limits.h>
#include <libexplain/ac/stdlib.h>
#include <libexplain/ac/string.h>
#include <libexplain/ac/sys/param.h>
#include <libexplain/ac/sys/stat.h>
#include <libexplain/buffer/get_current_directory.h>
#include <libexplain/buffer/gettext.h>
#include <libexplain/buffer/errno/fstat.h>
#include <libexplain/buffer/errno/stat.h>
#include <libexplain/buffer/errno/path_resolution.h>
#include <libexplain/fileinfo.h>
#include <libexplain/is_same_inode.h>
#include <libexplain/name_max.h>

Go to the source code of this file.

Functions

static int recursive_pwd (explain_string_buffer_t *sb, explain_string_buffer_t *dot, const struct stat *dot_st, explain_string_buffer_t *result)
int explain_buffer_get_current_directory (explain_string_buffer_t *sb, char *data, size_t data_size)

Function Documentation

int explain_buffer_get_current_directory ( explain_string_buffer_t sb,
char *  data,
size_t  data_size 
)

The explain_buffer_get_current_directory function may be used to obtain the path of the current directory, printing errors as and when they are found.

Parameters:
sbThe string buffer to print into.
dataThe buffer to place the generated path into, once found
data_sizeThe siz eof the buffer, in bytes.
Returns:
int; 0 in success (path found, no errors), or -1 when path not found and message already printed.

Definition at line 234 of file get_current_directory.c.

static int recursive_pwd ( explain_string_buffer_t sb,
explain_string_buffer_t dot,
const struct stat *  dot_st,
explain_string_buffer_t result 
) [static]

The recursive_pwd function is used to recursively walk up the ".." chain until "/" is reached, and then glue on the discovered directory entry names as it unwinds.

Parameters:
sbThe string buffer to print error messages into.
dotThe string buffer to build the ".." chain into.
dot_stThe file status information of the drectory entry to search ".." for.
resultThe constructed pathname as parent names are discovered.
Returns:
int; 0 if a path was found, -1 if no peth could be found AND an error message has already been printed.

Definition at line 56 of file get_current_directory.c.