39 lines
816 B
C
39 lines
816 B
C
#ifndef CPATH_H
|
|
#define CPATH_H
|
|
|
|
#include "aliases.h"
|
|
#include "mem_allocator.h"
|
|
#include "platform.h"
|
|
#include "str8.h"
|
|
|
|
#ifdef __cplusplus
|
|
BEGIN_C_LINKAGE
|
|
#endif // __cplusplus
|
|
|
|
#ifdef WAPP_PLATFORM_POSIX
|
|
#define PATH_SEP '/'
|
|
#elif defined(WAPP_PLATFORM_WINDOWS)
|
|
#define PATH_SEP '\\'
|
|
#else
|
|
#error "Unrecognised platform"
|
|
#endif
|
|
|
|
#define wapp_cpath_dirname(ALLOCATOR, PATH) dirup(ALLOCATOR, PATH, 1)
|
|
#define wapp_cpath_dirup(ALLOCATOR, PATH, COUNT) dirup(ALLOCATOR, PATH, 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);
|
|
Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels);
|
|
|
|
#ifdef __cplusplus
|
|
END_C_LINKAGE
|
|
#endif // __cplusplus
|
|
|
|
#endif // !CPATH_H
|