Switch wapp_cpath_join_path to use Str8

This commit is contained in:
2025-02-22 17:48:25 +00:00
parent ba5e902a1d
commit ed4ec54c7a
4 changed files with 107 additions and 68 deletions

View File

@@ -3,6 +3,7 @@
#include "aliases.h"
#include "platform.h"
#include "str8.h"
#ifdef __cplusplus
BEGIN_C_LINKAGE
@@ -16,13 +17,17 @@ BEGIN_C_LINKAGE
#error "Unrecognised platform"
#endif
#define NUMPARTS(...) (sizeof((const char *[]){"", __VA_ARGS__}) / sizeof(const char *) - 1)
#define wapp_cpath_join_path(DST, ...) join_path(DST, NUMPARTS(__VA_ARGS__), __VA_ARGS__)
#define wapp_cpath_dirname(DST, PATH) dirup(DST, 1, PATH)
#define wapp_cpath_dirup(DST, COUNT, PATH) dirup(DST, COUNT, PATH)
void join_path(char *dst, u64 count, ...);
enum {
CPATH_JOIN_SUCCESS = 0,
CPATH_JOIN_INVALID_ARGS,
CPATH_JOIN_EMPTY_PARTS,
CPATH_JOIN_INSUFFICIENT_DST_CAPACITY,
};
u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts);
void dirup(char *dst, u64 levels, const char *path);
#ifdef __cplusplus