30#include <kernel/types.h>
32#include <utils/compiler.h>
38#define LIBPATH_SEPARATOR '/'
49#define NEW_PATH(_path, _len) \
52 .path = (_path), .len = (_len) \
58#define NEW_DYNAMIC_PATH(_path) NEW_PATH((_path), strlen((_path)))
127#define DO_FOREACH_SEGMENT(_segment, _path, _body) \
129 path_segment_t _segment; \
130 if (path_walk_first((_path), &(_segment))) { \
133 } while (path_walk_next(&(_segment))); \
140 return segment->
prev == NULL;
146 return segment->
next == NULL;
152 if (segment->
end == NULL) {
158 return segment->
end - segment->
start;
bool path_segment_is(const char *, const path_segment_t *)
Definition: path.c:170
static ALWAYS_INLINE bool path_segment_is_first(const path_segment_t *segment)
Check whether a segment is the first of ots containing path.
Definition: path.h:138
static ALWAYS_INLINE bool path_segment_is_last(const path_segment_t *segment)
Check whether a segment is the first of ots containing path.
Definition: path.h:144
bool path_walk_last(const path_t *, path_segment_t *)
Retrieve the last segment of a path.
Definition: path.c:109
static ALWAYS_INLINE size_t path_segment_length(const path_segment_t *segment)
Retieve the length of a segment's content.
Definition: path.h:150
bool path_walk_next(path_segment_t *segment)
Retrieve the next segment.
Definition: path.c:138
bool path_walk_first(const path_t *, path_segment_t *)
Retrieve the first segment of a path.
Definition: path.c:98
bool path_walk_prev(path_segment_t *segment)
Retrieve the previous segment.
Definition: path.c:153
ssize_t path_load_parent(char *parent, const path_t *path, size_t size)
Store the raw path of path's parent inside a string.
Definition: path.c:176
static bool path_is_absolute(const path_t *path)
Check whether a path is an absolute one.
Definition: path.h:61
static bool path_is_empty(const path_t *path)
Check whether a path is empty.
Definition: path.h:67
#define LIBPATH_SEPARATOR
Path separator.
Definition: path.h:38
Safer wrapper around a string symbolizing a path.
Definition: path.h:43
size_t len
The length of the raw string.
Definition: path.h:45
const char * path
Original raw string containing the full path.
Definition: path.h:44
A single path component.
Definition: path.h:107
const char * next
Start of the next segment.
Definition: path.h:114
const char * start
Start of the segment.
Definition: path.h:108
const path_t * path
The original path the segment is a part of.
Definition: path.h:110
const char * prev
Start of the previous segment.
Definition: path.h:118
const char * end
End of the segment.
Definition: path.h:109