From 9c0b2479f7025a84444adf08e3be8ced60dad013 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 1 Aug 2010 16:15:27 +0000 Subject: Rockbox as an application: add get_user_file_path(). For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox). This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local. On the DAPs it's a no-op, returing /.rockbox directly. Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apps/playlist.c') diff --git a/apps/playlist.c b/apps/playlist.c index 4a6db883f7..2896f62e76 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -86,6 +86,7 @@ #include "screens.h" #include "buffer.h" #include "misc.h" +#include "filefuncs.h" #include "button.h" #include "filetree.h" #include "abrepeat.h" @@ -103,7 +104,6 @@ #include "rbunicode.h" #include "root_menu.h" -#define PLAYLIST_CONTROL_FILE ROCKBOX_DIR "/.playlist_control" #define PLAYLIST_CONTROL_FILE_VERSION 2 /* @@ -1440,7 +1440,12 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion) /* process random folder advance */ if (global_settings.next_folder == FOLDER_ADVANCE_RANDOM) { - int fd = open(ROCKBOX_DIR "/folder_advance_list.dat", O_RDONLY); + char folder_advance_list[MAX_PATH]; + get_user_file_path(ROCKBOX_DIR, FORCE_BUFFER_COPY, + folder_advance_list, sizeof(folder_advance_list)); + strlcat(folder_advance_list, "/folder_advance_list.dat", + sizeof(folder_advance_list)); + int fd = open(folder_advance_list, O_RDONLY); if (fd >= 0) { char buffer[MAX_PATH]; @@ -1910,7 +1915,8 @@ void playlist_init(void) struct playlist_info* playlist = ¤t_playlist; playlist->current = true; - strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, + get_user_file_path(PLAYLIST_CONTROL_FILE, IS_FILE|NEED_WRITE|FORCE_BUFFER_COPY, + playlist->control_filename, sizeof(playlist->control_filename)); playlist->fd = -1; playlist->control_fd = -1; -- cgit v1.2.3