| 73 | } |
| 74 | |
| 75 | const char *cbm_path_ext(const char *path) { |
| 76 | if (!path) { |
| 77 | return ""; |
| 78 | } |
| 79 | const char *dot = NULL; |
| 80 | const char *slash = NULL; |
| 81 | for (const char *p = path; *p; p++) { |
| 82 | if (*p == '.') { |
| 83 | dot = p; |
| 84 | } |
| 85 | if (*p == '/') { |
| 86 | slash = p; |
| 87 | } |
| 88 | } |
| 89 | /* dot must be after last slash and not at start of basename */ |
| 90 | if (!dot) { |
| 91 | return ""; |
| 92 | } |
| 93 | if (slash && dot < slash) { |
| 94 | return ""; |
| 95 | } |
| 96 | return dot + SKIP_ONE; |
| 97 | } |
| 98 | |
| 99 | const char *cbm_path_base(const char *path) { |
| 100 | if (!path) { |