| 524 | } |
| 525 | |
| 526 | char **path_split(const tal_t *ctx, const char *path) |
| 527 | { |
| 528 | bool empty = path && !path[0]; |
| 529 | char **ret = tal_strsplit(ctx, path, PATH_SEP_STR, STR_NO_EMPTY); |
| 530 | |
| 531 | /* Handle the "/" case */ |
| 532 | if (ret && !empty && !ret[0]) { |
| 533 | if (!tal_resize(&ret, 2)) |
| 534 | ret = tal_free(ret); |
| 535 | else { |
| 536 | ret[1] = NULL; |
| 537 | ret[0] = tal_strdup(ret, PATH_SEP_STR); |
| 538 | if (!ret[0]) |
| 539 | ret = tal_free(ret); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | return ret; |
| 544 | } |
| 545 | |
| 546 | size_t path_ext_off(const char *path) |
| 547 | { |