The directory of normalised path `p` ("/" for "/x", "" for "x"). */
| 768 | |
| 769 | /* The directory of normalised path `p` ("/" for "/x", "" for "x"). */ |
| 770 | static const char *dk_dir(dk_t *d, const char *p) { |
| 771 | const char *s = strrchr(p, '/'); |
| 772 | if (!s) { |
| 773 | return ""; |
| 774 | } |
| 775 | if (s == p) { |
| 776 | return "/"; |
| 777 | } |
| 778 | char *out = cbm_arena_alloc(d->a, (size_t)(s - p) + SKIP_ONE); |
| 779 | if (out) { |
| 780 | memcpy(out, p, (size_t)(s - p)); |
| 781 | out[s - p] = '\0'; |
| 782 | } |
| 783 | return out; |
| 784 | } |
| 785 | |
| 786 | static bool dk_ends(const char *s, const char *suffix) { |
| 787 | size_t l = strlen(s); |
no test coverage detected