diff options
author | Vincent Douillet <vincent@vdouillet.fr> | 2024-12-24 11:52:50 +0100 |
---|---|---|
committer | Vincent Douillet <vincent@vdouillet.fr> | 2024-12-26 10:49:13 +0100 |
commit | 2e04b2c23c66a42372d0ecaea2b0f4b2c7b7c7e5 (patch) | |
tree | 9249bb0e9792a11bb27df78a4d93a0b3c0be0b33 /file.c | |
parent | 878cd6e8792d5ac03eea59fec9fe8e325440d50c (diff) |
delete files
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -140,8 +140,24 @@ file_get_basename(const struct file * f) if (strrchr(f->path, '/') == NULL) return f->path; - /* split for the basename */ - return str_split(f->path, '/'); + /* get the basename */ + return str_tail(f->path, '/'); +} + +struct file * +file_get_parent(const struct file * f) +{ + char *head; + struct file *parent; + + head = str_head(f->path, '/'); + if (head == NULL) + return file_new(""); + + parent = file_new(head); + + free(head); + return parent; } size_t |