Paths

API for handling filesystem paths.

Functions

oc_path_slice_directory

oc_str8 oc_path_slice_directory(oc_str8 path);

Get a string slice of the directory part of a path.

Parameters

  • path The path to slice.

oc_path_slice_filename

oc_str8 oc_path_slice_filename(oc_str8 path);

Get a string slice of the file name part of a path.

Parameters

  • path The path to slice

oc_path_split

oc_str8_list oc_path_split(oc_arena* arena, oc_str8 path);

Split a path into path elements.

Parameters

  • arena An arena on which to allocate string list elements.
  • path The path to slice.

Return

A string list of path elements. The strings in this list are slices into the input path, refering to the same backing memory.


oc_path_join

oc_str8 oc_path_join(oc_arena* arena, oc_str8_list elements);

Join path elements to form a path.

Parameters

  • arena An arena on which to allocate the resulting path.
  • elements A string list of path elements.

Return

The resulting path.


oc_path_append

oc_str8 oc_path_append(oc_arena* arena, oc_str8 parent, oc_str8 relPath);

Append a path to another path.

Parameters

  • arena An arena on which to allocate the resulting path.
  • parent The first part of the path.
  • relPath The relative path to append.

Return

The resulting path.


oc_path_is_absolute

bool oc_path_is_absolute(oc_str8 path);

Test wether a path is an absolute path.

Parameters

  • path The path to test.

Return

true if the path is absolute, false otherwise.