| 110 | } |
| 111 | |
| 112 | char *cbm_path_dir(CBMArena *a, const char *path) { |
| 113 | if (!path) { |
| 114 | return cbm_arena_strdup(a, "."); |
| 115 | } |
| 116 | const char *last_slash = NULL; |
| 117 | for (const char *p = path; *p; p++) { |
| 118 | if (*p == '/') { |
| 119 | last_slash = p; |
| 120 | } |
| 121 | } |
| 122 | if (!last_slash) { |
| 123 | return cbm_arena_strdup(a, "."); |
| 124 | } |
| 125 | return cbm_arena_strndup(a, path, (size_t)(last_slash - path)); |
| 126 | } |
| 127 | |
| 128 | bool cbm_str_starts_with(const char *s, const char *prefix) { |
| 129 | if (!s || !prefix) { |
no test coverage detected