diff options
-rw-r--r-- | src/platform/path.c | 17 | ||||
-rw-r--r-- | xmake.lua | 12 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/platform/path.c b/src/platform/path.c index 31fa59c..3607089 100644 --- a/src/platform/path.c +++ b/src/platform/path.c @@ -16,5 +16,20 @@ path_opt path_parent(arena* a, const char* path) { } #endif #ifdef CEL_PLATFORM_WINDOWS -path_opt path_parent(arena* a, const char* path) {} +#include <windows.h> +#include <shlwapi.h> +#pragma comment(lib, "Shlwapi.lib") + +path_opt path_parent(arena* a, const char* path) { + // Duplicate the string because PathRemoveFileSpec mutates in-place + size_t len = strlen(path) + 1; + char* path_copy = arena_alloc(a, len); + strcpy_s(path_copy, len, path); + + if (PathRemoveFileSpecA(path_copy)) { + return (path_opt){ .path = Str8_cstr_view(path_copy), .has_value = true }; + } else { + return (path_opt){ .has_value = false}; + } +} #endif @@ -24,7 +24,7 @@ if is_plat("linux") then elseif is_plat("windows") then add_defines("CEL_PLATFORM_WINDOWS") add_syslinks("user32", "gdi32", "kernel32", "shell32") - add_requires("vulkansdk", { system = true }) + -- add_requires("vulkansdk", { system = true }) -- add_links("pthreadVC2-w64") elseif is_plat("macosx") then @@ -138,9 +138,9 @@ add_files("src/empty.c") -- for some reason we need this on Mac so it doesnt cal -- add_files("assets/shaders/cube.frag") -- add_files("assets/shaders/*.frag") if is_plat("windows") then - add_includedirs("$(env VULKAN_SDK)/Include", { public = true }) - add_linkdirs("$(env VULKAN_SDK)/Lib", { public = true }) - add_links("vulkan-1") + -- add_includedirs("$(env VULKAN_SDK)/Include", { public = true }) + -- add_linkdirs("$(env VULKAN_SDK)/Lib", { public = true }) + -- add_links("vulkan-1") end if is_plat("macosx") then -- add_files("src/renderer/backends/metal/*.m") @@ -155,7 +155,7 @@ set_policy("build.merge_archive", true) add_files(core_sources) -- Link against static CRT if is_plat("windows") then - add_links("libcmt", "legacy_stdio_definitions") -- for release builds + -- add_links("libcmt", "legacy_stdio_definitions") -- for release builds add_links("libcmtd", "legacy_stdio_definitions") -- for debug builds end @@ -165,7 +165,7 @@ add_deps("core_config") -- inherit common configurations add_files(core_sources) -- Link against dynamic CRT if is_plat("windows") then - add_links("msvcrt", "legacy_stdio_definitions") -- for release builds + -- add_links("msvcrt", "legacy_stdio_definitions") -- for release builds add_links("msvcrtd", "legacy_stdio_definitions") -- for debug builds end |