diff options
| author | Louis Burda <quent.burda@gmail.com> | 2022-02-26 03:21:10 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2022-02-26 03:21:10 +0100 |
| commit | c22fd8aeac8906739cf947b7da732876efba8d20 (patch) | |
| tree | e389a0eb085bdb019708a48eda575a97a320ec12 /src/data.c | |
| parent | 53cb5a2a0d1540a37e6e5d1c1673e8354d5208a5 (diff) | |
| download | tmus-c22fd8aeac8906739cf947b7da732876efba8d20.tar.gz tmus-c22fd8aeac8906739cf947b7da732876efba8d20.zip | |
Keybind for seek to playing, keybind for delete
Diffstat (limited to 'src/data.c')
| -rw-r--r-- | src/data.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -6,6 +6,7 @@ #include "ref.h" #include "track.h" #include "tag.h" +#include "tui.h" #include <fts.h> #include <dirent.h> @@ -319,6 +320,44 @@ tracks_save(struct tag *tag) } bool +track_rm(struct track *track) +{ + struct link *link; + struct ref *ref; + struct tag *tag; + bool found; + + if (!rm_file(track->fpath)) { + CMD_SET_STATUS("Failed to remove track"); + return false; + } + + found = false; + for (LIST_ITER(&tracks, link)) { + ref = UPCAST(link, struct ref); + if (ref->data == track) { + link_pop(link); + ref_free(ref); + found = true; + break; + } + } + + for (LIST_ITER(&track->tags, link)) { + ref = UPCAST(link, struct ref); + tag = ref->data; + refs_rm(&tag->tracks, track); + } + + if (player.track == track) + player.track = NULL; + + track_free(track); + + return true; +} + +bool make_dir(const char *path) { return mkdir(path, S_IRWXU | S_IRWXG) == 0; |
