summaryrefslogtreecommitdiff
path: root/src/platform/platform_windows.c
blob: 21ef359ef039d0c6f1514fcf2c1a2ef8e8e726fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "platform.h"

#if defined(CEL_PLATFORM_WINDOWS)

#include <shlwapi.h>
#include <windows.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