diff options
author | Thomas Jarosch <tomj@simonv.com> | 2011-02-15 21:13:03 +0000 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2011-02-15 21:13:03 +0000 |
commit | 81614c428c8edb335d8498051ac5a5e2216ef394 (patch) | |
tree | 8aa2f04f395f02f981a6f8f660fcde5e53a6702a /apps | |
parent | 2f3ab5fa22ba9b5824388ee3f6cff747ea720ab2 (diff) | |
download | rockbox-81614c428c8edb335d8498051ac5a5e2216ef394.tar.gz rockbox-81614c428c8edb335d8498051ac5a5e2216ef394.zip |
RaaA: Fix last.FM scrobbler log file location
The .scrobbler.log or .scrobbler-timeless.log file
resides in the USB mass storage area. The exact location
differs for every RaaA platform.
The SDL platform sticks it in ROCKBOX_DIR for now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29314 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/scrobbler.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/apps/scrobbler.c b/apps/scrobbler.c index 9b0decfb68..c909737aac 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c | |||
@@ -45,12 +45,6 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging | |||
45 | 45 | ||
46 | #define SCROBBLER_VERSION "1.1" | 46 | #define SCROBBLER_VERSION "1.1" |
47 | 47 | ||
48 | #if CONFIG_RTC | ||
49 | #define SCROBBLER_FILE "/.scrobbler.log" | ||
50 | #else | ||
51 | #define SCROBBLER_FILE "/.scrobbler-timeless.log" | ||
52 | #endif | ||
53 | |||
54 | /* increment this on any code change that effects output */ | 48 | /* increment this on any code change that effects output */ |
55 | #define SCROBBLER_REVISION " $Revision$" | 49 | #define SCROBBLER_REVISION " $Revision$" |
56 | 50 | ||
@@ -78,16 +72,47 @@ unsigned long audio_prev_elapsed(void) | |||
78 | } | 72 | } |
79 | #endif | 73 | #endif |
80 | 74 | ||
75 | static void get_scrobbler_filename(char *path, size_t size) | ||
76 | { | ||
77 | int used; | ||
78 | |||
79 | #if CONFIG_RTC | ||
80 | const char *base_filename = ".scrobbler.log"; | ||
81 | #else | ||
82 | const char *base_filename = ".scrobbler-timeless.log"; | ||
83 | #endif | ||
84 | |||
85 | /* Get location of USB mass storage area */ | ||
86 | #if APPLICATION && (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
87 | used = snprintf(path, size, "/home/user/MyDocs/%s", base_filename); | ||
88 | #elif APPLICATION && (CONFIG_PLATFORM & PLATFORM_ANDROID) | ||
89 | used = snprintf(path, size, "/sdcard/%s", base_filename); | ||
90 | #elif APPLICATION && (CONFIG_PLATFORM & PLATFORM_SDL) | ||
91 | used = snprintf(path, size, "%s/%s", ROCKBOX_DIR, base_filename); | ||
92 | #else | ||
93 | used = snprintf(path, size, "/%s", base_filename); | ||
94 | #endif | ||
95 | |||
96 | if (used >= (int)size) | ||
97 | { | ||
98 | logf("SCROBBLER: not enough buffer space for log file"); | ||
99 | memset(path, 0, size); | ||
100 | } | ||
101 | } | ||
102 | |||
81 | static void write_cache(void) | 103 | static void write_cache(void) |
82 | { | 104 | { |
83 | int i; | 105 | int i; |
84 | int fd; | 106 | int fd; |
85 | 107 | ||
108 | char scrobbler_file[MAX_PATH]; | ||
109 | get_scrobbler_filename(scrobbler_file, MAX_PATH); | ||
110 | |||
86 | /* If the file doesn't exist, create it. | 111 | /* If the file doesn't exist, create it. |
87 | Check at each write since file may be deleted at any time */ | 112 | Check at each write since file may be deleted at any time */ |
88 | if(!file_exists(SCROBBLER_FILE)) | 113 | if(!file_exists(scrobbler_file)) |
89 | { | 114 | { |
90 | fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT, 0666); | 115 | fd = open(scrobbler_file, O_RDWR | O_CREAT, 0666); |
91 | if(fd >= 0) | 116 | if(fd >= 0) |
92 | { | 117 | { |
93 | fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n" | 118 | fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n" |
@@ -107,7 +132,7 @@ static void write_cache(void) | |||
107 | } | 132 | } |
108 | 133 | ||
109 | /* write the cache entries */ | 134 | /* write the cache entries */ |
110 | fd = open(SCROBBLER_FILE, O_WRONLY | O_APPEND); | 135 | fd = open(scrobbler_file, O_WRONLY | O_APPEND); |
111 | if(fd >= 0) | 136 | if(fd >= 0) |
112 | { | 137 | { |
113 | logf("SCROBBLER: writing %d entries", cache_pos); | 138 | logf("SCROBBLER: writing %d entries", cache_pos); |