diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-11-17 13:00:50 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-11-17 13:00:50 +0000 |
commit | 4bd3e61de9618dcc021f9626039c22667429ed33 (patch) | |
tree | 5b03b89668343a685218dfd2f4991e9aead9d057 /apps/plugins | |
parent | 335190567c5990aa984f965cc09ccebb6941931e (diff) |
The favorites plugin can now be a viewer as well
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5418 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/favorites.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/apps/plugins/favorites.c b/apps/plugins/favorites.c index 949eeeae31..c4b969f920 100644 --- a/apps/plugins/favorites.c +++ b/apps/plugins/favorites.c @@ -7,37 +7,35 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { struct mp3entry* id3; char track_path[MAX_PATH+1]; - int fd, seek, result, len; + int fd, result, len; /* this macro should be called as the first thing you do in the plugin. it test that the api version and model the plugin was compiled for matches the machine it is running on */ TEST_PLUGIN_API(api); - /* if you don't use the parameter, you can do like - this to avoid the compiler warning about it */ - (void)parameter; - rb = api; - id3 = rb->mpeg_current_track(); - if (!id3) { - rb->splash(HZ*2, true, "Nothing To Save"); - return PLUGIN_OK; - } - - fd = rb->open(FAVORITES_FILE, O_WRONLY); + /* If we were passed a parameter, use that as the file name, + else take the currently playing track */ + if(parameter) { + rb->strncpy(track_path, parameter, MAX_PATH); + } else { + id3 = rb->mpeg_current_track(); + if (!id3) { + rb->splash(HZ*2, true, "Nothing To Save"); + return PLUGIN_OK; + } + rb->strncpy(track_path, id3->path, MAX_PATH); + } - // creat the file if it does not return on open. - if (fd < 0) - fd = rb->creat(FAVORITES_FILE, 0); + track_path[MAX_PATH] = 0; + + len = rb->strlen(track_path); - if (fd > 0) { - rb->strcpy(track_path, id3->path); - len = rb->strlen(track_path); + fd = rb->open(FAVORITES_FILE, O_CREAT|O_WRONLY|O_APPEND); - // seek to the end of file - seek = rb->lseek(fd, 0, SEEK_END); + if (fd >= 0) { // append the current mp3 path track_path[len] = '\n'; result = rb->write(fd, track_path, len + 1); @@ -49,5 +47,3 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) return PLUGIN_OK; } - - |