46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
// vim:fileencoding=utf-8:foldmethod=marker
|
|
|
|
#ifndef CPATH_H
|
|
#define CPATH_H
|
|
|
|
#include "../../common/aliases/aliases.h"
|
|
#include "../../common/platform/platform.h"
|
|
#include "../../base/mem/allocator/mem_allocator.h"
|
|
#include "../../base/strings/str8/str8.h"
|
|
|
|
#ifdef WP_PLATFORM_CPP
|
|
BEGIN_C_LINKAGE
|
|
#endif // !WP_PLATFORM_CPP
|
|
|
|
#ifdef WP_PLATFORM_POSIX
|
|
#include <limits.h>
|
|
#define WP_PATH_SEP '/'
|
|
#define WP_PATH_MAX PATH_MAX
|
|
#elif defined(WP_PLATFORM_WINDOWS)
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
#define WP_PATH_SEP '\\'
|
|
#define WP_PATH_MAX MAX_PATH
|
|
#else
|
|
#error "Unrecognised platform"
|
|
#endif
|
|
|
|
#define wpCpathDirname(ALLOCATOR, PATH) dirUp(ALLOCATOR, PATH, 1)
|
|
#define wpCpathDirUp(ALLOCATOR, PATH, COUNT) dirUp(ALLOCATOR, PATH, COUNT)
|
|
|
|
typedef enum WpCpathJoinResult {
|
|
WP_CPATH_JOIN_RESULT_SUCCESS = 0,
|
|
WP_CPATH_JOIN_RESULT_INVALID_ARGS,
|
|
WP_CPATH_JOIN_RESULT_EMPTY_PARTS,
|
|
WP_CPATH_JOIN_RESULT_INSUFFICIENT_DST_CAPACITY,
|
|
} WpCpathJoinResult;
|
|
|
|
WpCpathJoinResult wpCpathJoinPath(WpStr8 *dst, const WpStr8List *parts);
|
|
WpStr8 *dirUp(const WpAllocator *allocator, WpStr8RO *path, u64 levels);
|
|
|
|
#ifdef WP_PLATFORM_CPP
|
|
END_C_LINKAGE
|
|
#endif // !WP_PLATFORM_CPP
|
|
|
|
#endif // !CPATH_H
|