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
This commit is contained in:
Thomas Jarosch 2011-02-15 21:13:03 +00:00
parent 2f3ab5fa22
commit 81614c428c

View file

@ -45,12 +45,6 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging
#define SCROBBLER_VERSION "1.1"
#if CONFIG_RTC
#define SCROBBLER_FILE "/.scrobbler.log"
#else
#define SCROBBLER_FILE "/.scrobbler-timeless.log"
#endif
/* increment this on any code change that effects output */
#define SCROBBLER_REVISION " $Revision$"
@ -78,16 +72,47 @@ unsigned long audio_prev_elapsed(void)
}
#endif
static void get_scrobbler_filename(char *path, size_t size)
{
int used;
#if CONFIG_RTC
const char *base_filename = ".scrobbler.log";
#else
const char *base_filename = ".scrobbler-timeless.log";
#endif
/* Get location of USB mass storage area */
#if APPLICATION && (CONFIG_PLATFORM & PLATFORM_MAEMO)
used = snprintf(path, size, "/home/user/MyDocs/%s", base_filename);
#elif APPLICATION && (CONFIG_PLATFORM & PLATFORM_ANDROID)
used = snprintf(path, size, "/sdcard/%s", base_filename);
#elif APPLICATION && (CONFIG_PLATFORM & PLATFORM_SDL)
used = snprintf(path, size, "%s/%s", ROCKBOX_DIR, base_filename);
#else
used = snprintf(path, size, "/%s", base_filename);
#endif
if (used >= (int)size)
{
logf("SCROBBLER: not enough buffer space for log file");
memset(path, 0, size);
}
}
static void write_cache(void)
{
int i;
int fd;
char scrobbler_file[MAX_PATH];
get_scrobbler_filename(scrobbler_file, MAX_PATH);
/* If the file doesn't exist, create it.
Check at each write since file may be deleted at any time */
if(!file_exists(SCROBBLER_FILE))
if(!file_exists(scrobbler_file))
{
fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT, 0666);
fd = open(scrobbler_file, O_RDWR | O_CREAT, 0666);
if(fd >= 0)
{
fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n"
@ -107,7 +132,7 @@ static void write_cache(void)
}
/* write the cache entries */
fd = open(SCROBBLER_FILE, O_WRONLY | O_APPEND);
fd = open(scrobbler_file, O_WRONLY | O_APPEND);
if(fd >= 0)
{
logf("SCROBBLER: writing %d entries", cache_pos);