From 1c6ec0b7b8e437a003137428636149132d998357 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:35:40 +1100 Subject: added a path_parent function to get path of a file Now we can load .mtl files without hardcoding the full path from top-level like before. that was a hack! --- src/platform/path.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/platform/path.c (limited to 'src/platform/path.c') diff --git a/src/platform/path.c b/src/platform/path.c new file mode 100644 index 0000000..e67102b --- /dev/null +++ b/src/platform/path.c @@ -0,0 +1,15 @@ +#include "path.h" + +#include +#include +#include "str.h" + +#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC) +path_opt path_parent(const char* path) { + char* path_dirname = dirname(path); + return (path_opt){ .path = str8_cstr_view(path_dirname), .has_value = true }; +} +#endif +#ifdef CEL_PLATFORM_WINDOWS +// TODO: path_opt path_parent(const char* path) +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2