| 547 | } |
| 548 | |
| 549 | char **path_split(const tal_t *ctx, const char *path) |
| 550 | { |
| 551 | bool empty = path && !path[0]; |
| 552 | char **ret = tal_strsplit(ctx, path, PATH_SEP_STR, STR_NO_EMPTY); |
| 553 | |
| 554 | /* Handle the "/" case */ |
| 555 | if (ret && !empty && !ret[0]) { |
| 556 | if (!tal_resize(&ret, 2)) |
| 557 | ret = tal_free(ret); |
| 558 | else { |
| 559 | ret[1] = NULL; |
| 560 | ret[0] = tal_strdup(ret, PATH_SEP_STR); |
| 561 | if (!ret[0]) |
| 562 | ret = tal_free(ret); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | return ret; |
| 567 | } |
| 568 | |
| 569 | size_t path_ext_off(const char *path) |
| 570 | { |