1#pragma once
2
3/*
4 * Path manipulation functions
5 */
6
7#include <pw.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13[[nodiscard]] bool pw_path_split(PwValuePtr path, PwValuePtr result);
14[[nodiscard]] bool pw_path_join(PwValuePtr parts, PwValuePtr result);
15
16[[nodiscard]] bool pw_path_as_string(PwValuePtr path, PwValuePtr result);
17/*
18 * Join path if it's an array or clone if it's a string.
19 */
20
21[[nodiscard]] bool pw_path_as_array(PwValuePtr path, PwValuePtr result);
22/*
23 * Split path if it's a string or clone if it's an array.
24 */
25
26[[nodiscard]] bool pw_path_normalize(PwValuePtr path, PwValuePtr result);
27/*
28 * `path` can be either string or array.
29 * `result` inherits `path`'s type
30 */
31
32[[nodiscard]] bool pw_basename(PwValuePtr filename, PwValuePtr result);
33[[nodiscard]] bool pw_dirname(PwValuePtr filename, PwValuePtr result);
34
35#define pw_path(result, ...) \
36 _pw_path_va((result) __VA_OPT__(,) __VA_ARGS__, PwVaEnd())
37
38[[nodiscard]] bool _pw_path_va(PwValuePtr result, ...);
39
40#ifdef __cplusplus
41}
42#endif