41 #include <sys/param.h> 54 #define _(String) gettext(String) 74 #define PATH_UTILS_ERROR_BASE -3000 75 #define PATH_UTILS_ERROR_LIMIT (PATH_UTILS_ERROR_BASE+20) 81 #define IS_PATH_UTILS_ERROR(error) (((error) >= PATH_UTILS_ERROR_BASE) && ((error) < PATH_UTILS_ERROR_LIMIT)) 88 #define PATH_UTILS_ERROR_NOT_FULLY_NORMALIZED (PATH_UTILS_ERROR_BASE + 1) 135 int get_basename(
char *base_name,
size_t base_name_size,
const char *path);
156 int get_dirname(
char *dir_path,
size_t dir_path_size,
const char *path);
179 char *base_name,
size_t base_name_size,
204 int path_concat(
char *path,
size_t path_size,
const char *head,
const char *tail);
218 int make_path_absolute(
char *absolute_path,
size_t absolute_path_size,
const char *path);
268 char **
split_path(
const char *path,
int *count);
310 int normalize_path(
char *normalized_path,
size_t normalized_path_size,
const char *path);
331 size_t common_path_size,
333 const char *path1,
const char *path2);
376 const char *path,
struct stat *info,
int make_normalized_absolute_path(char *result_path, size_t result_path_size, const char *path)
Make the input path absolute if it's not already, then normalize it.
Definition: path_utils.c:511
int get_basename(char *base_name, size_t base_name_size, const char *path)
Get the basename component of a path.
Definition: path_utils.c:111
char ** split_path(const char *path, int *count)
Split a file system path into individual components.
Definition: path_utils.c:305
int make_path_absolute(char *absolute_path, size_t absolute_path_size, const char *path)
Convert a path into absolute.
Definition: path_utils.c:260
bool is_ancestor_path(const char *ancestor, const char *path)
Tell if one path is ancestor of another.
Definition: path_utils.c:610
int directory_list(const char *path, bool recursive, directory_list_callback_t callback, void *user_data)
Walk a directory.
Definition: path_utils.c:552
int normalize_path(char *normalized_path, size_t normalized_path_size, const char *path)
Normalizes a path.
Definition: path_utils.c:371
int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const char *path)
Definition: path_utils.c:523
int get_dirname(char *dir_path, size_t dir_path_size, const char *path)
Copy the directory components of a path.
Definition: path_utils.c:132
const char * path_utils_error_string(int error)
Given an error code return the string description.
Definition: path_utils.c:77
int common_path_prefix(char *common_path, size_t common_path_size, int *common_count, const char *path1, const char *path2)
Find the common prefix between two paths.
Definition: path_utils.c:447
bool(* directory_list_callback_t)(const char *directory, const char *base_name, const char *path, struct stat *info, void *user_data)
callback for the directory_list() function
Definition: path_utils.h:375
int get_directory_and_base_name(char *dir_path, size_t dir_path_size, char *base_name, size_t base_name_size, const char *path)
Get the basaname and directory components of a path.
Definition: path_utils.c:153
int path_concat(char *path, size_t path_size, const char *head, const char *tail)
Concatenate two components of a path.
Definition: path_utils.c:193
bool is_absolute_path(const char *path)
Tell if path is absolute or relative.
Definition: path_utils.c:187