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)
135int get_basename(
char *base_name,
size_t base_name_size,
const char *path);
156int get_dirname(
char *dir_path,
size_t dir_path_size,
const char *path);
179 char *base_name,
size_t base_name_size,
204int path_concat(
char *path,
size_t path_size,
const char *head,
const char *tail);
218int make_path_absolute(
char *absolute_path,
size_t absolute_path_size,
const char *path);
268char **
split_path(
const char *path,
int *count);
310int 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:515
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 path_concat(char *path, size_t path_size, const char *head, const char *tail)
Concatenate two components of a path.
Definition path_utils.c:197
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:155
int make_path_absolute(char *absolute_path, size_t absolute_path_size, const char *path)
Convert a path into absolute.
Definition path_utils.c:264
bool is_ancestor_path(const char *ancestor, const char *path)
Tell if one path is ancestor of another.
Definition path_utils.c:615
int directory_list(const char *path, bool recursive, directory_list_callback_t callback, void *user_data)
Walk a directory.
Definition path_utils.c:557
int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const char *path)
Definition path_utils.c:527
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:451
const char * path_utils_error_string(int error)
Given an error code return the string description.
Definition path_utils.c:77
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:133
char ** split_path(const char *path, int *count)
Split a file system path into individual components.
Definition path_utils.c:309
bool is_absolute_path(const char *path)
Tell if path is absolute or relative.
Definition path_utils.c:191
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
int normalize_path(char *normalized_path, size_t normalized_path_size, const char *path)
Normalizes a path.
Definition path_utils.c:375