My Kernel v0.1.0
Path walking

Walking along a path. More...

Collaboration diagram for Path walking:

Data Structures

struct  libpath_segment
 A single path component. More...
 

Macros

#define DO_FOREACH_SEGMENT(_segment, _path, _body)
 Loop over all the segments of a given path. More...
 

Functions

static ALWAYS_INLINE bool path_segment_is_first (const path_segment_t *segment)
 Check whether a segment is the first of ots containing path.
 
static ALWAYS_INLINE bool path_segment_is_last (const path_segment_t *segment)
 Check whether a segment is the first of ots containing path.
 
static ALWAYS_INLINE size_t path_segment_length (const path_segment_t *segment)
 Retieve the length of a segment's content.
 
bool path_walk_first (const path_t *, path_segment_t *)
 Retrieve the first segment of a path. More...
 
bool path_walk_last (const path_t *, path_segment_t *)
 Retrieve the last segment of a path. More...
 
bool path_walk_next (path_segment_t *segment)
 Retrieve the next segment. More...
 
bool path_walk_prev (path_segment_t *segment)
 Retrieve the previous segment. More...
 
bool path_segment_is (const char *, const path_segment_t *)
 

Detailed Description

How to use

  1. Find the first/last segment of the path (path_walk_first/path_walk_last)
  2. Walk forward/backward (path_walk_next/path_walk_prev)

Macro Definition Documentation

◆ DO_FOREACH_SEGMENT

#define DO_FOREACH_SEGMENT (   _segment,
  _path,
  _body 
)
Value:
do { \
path_segment_t _segment; \
if (path_walk_first((_path), &(_segment))) { \
do { \
_body; \
} while (path_walk_next(&(_segment))); \
} \
} while (0)
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
A single path component.
Definition: path.h:107
Parameters
_segmentName of the iterator used by the loop to store the segment
_pathThe original path
_bodyThe body placed inside the loop

Function Documentation

◆ path_segment_is()

bool path_segment_is ( const char *  name,
const path_segment_t segment 
)
Returns
true if the segment name corresponds to the string

◆ path_walk_first()

bool path_walk_first ( const path_t path,
path_segment_t segment 
)

This function returns the first segment of the path.

Parameters
pathThe path to walk along
[out]segmentPointer to a struct which the segment will be stored into
Returns
false if no segment could be extracted, true otherwise

◆ path_walk_last()

bool path_walk_last ( const path_t path,
path_segment_t segment 
)

This function returns the last segment of the path.

Parameters
pathThe path to walk along
[out]segmentPointer to a struct which the segment will be stored into
Returns
false if no segment could be extracted, true otherwise

◆ path_walk_next()

bool path_walk_next ( path_segment_t segment)
Warning
The current content inside the segment's struct will be overriden with the information concerning the new segment.
Parameters
segmentThe current segment's information struct
Returns
false if there is no next segment, true otherwise

◆ path_walk_prev()

bool path_walk_prev ( path_segment_t segment)
Warning
The current content inside the segment's struct will be overriden with the information concerning the new segment.
Parameters
segmentThe current segment's information struct
Returns
false if there is no previous segment, true otherwise