Get the directory part of a relative path (without trailing slash). * Returns heap-allocated string. For "foo.json" returns "". */
| 140 | /* Get the directory part of a relative path (without trailing slash). |
| 141 | * Returns heap-allocated string. For "foo.json" returns "". */ |
| 142 | static char *path_dirname(const char *rel_path) { |
| 143 | const char *last = strrchr(rel_path, '/'); |
| 144 | if (!last) { |
| 145 | return strdup(""); |
| 146 | } |
| 147 | return cbm_strndup(rel_path, (size_t)(last - rel_path)); |
| 148 | } |
| 149 | |
| 150 | /* Strip file extension from a path. Returns heap-allocated string. |
| 151 | * "src/index.ts" → "src/index", "lib/main" → "lib/main" */ |
no test coverage detected