summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2012-06-02 00:12:54 -0400
committerMichael Giacomelli <mgiacomelli@gmail.com>2012-06-22 17:05:03 +0200
commitb30edcd62f2e16525bc9c6fe0b52769ae30b0dc8 (patch)
treee1809205f61c5387a581aa4061d4b644e4489172
parent0c3934f917ffec02123b691b6979d06eaa17137b (diff)
downloadrockbox-b30edcd62f2e16525bc9c6fe0b52769ae30b0dc8.tar.gz
rockbox-b30edcd62f2e16525bc9c6fe0b52769ae30b0dc8.tar.bz2
rockbox-b30edcd62f2e16525bc9c6fe0b52769ae30b0dc8.zip
Make playlist.c aware of external storage when determining paths
format_track_path currenyly corrects for things like windows volumes and relative paths in playlists, but does not handle external media like SD cards correctly, resulting in some seemingly valid playlists not working because of rockbox's mount point for external media. Correct this by checking to see if a playlist is on external media and then formulate the path correctly if it is. Unfortunately, this breaks the playlist_save logic if the CWD is on an external device. Its not clear to me why we should be checking the CWD when saving a playlist, as the only apparent use of this is to let people save relative paths on the virtual keyboard. As far as I can tell, this is actually more difficult to do then using an absolute path given that we insert the CWD onto the virtualkeyboard by default. Therefore, I'm removing the option to use '..' in playlist save paths since its seems useless. Change-Id: I47946cc45d776c7a72ecbd0ecc720dbf85550f6f Reviewed-on: http://gerrit.rockbox.org/270 Reviewed-by: Michael Giacomelli <mgiacomelli@gmail.com> Tested-by: Michael Giacomelli <mgiacomelli@gmail.com>
-rw-r--r--apps/playlist.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 42f0b30139..42c0d8b7c5 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1770,6 +1770,18 @@ static int format_track_path(char *dest, char *src, int buf_length, int max,
snprintf(dest, buf_length, "%s/%s", dir, src);
}
}
+#ifdef HAVE_MULTIVOLUME
+
+ char vol_string[VOL_ENUM_POS + 8];
+ snprintf(vol_string, sizeof(vol_string), "/"VOL_NAMES, 1);
+
+ /*check if the playlist is on a external card, and correct path if needed */
+ if(strstr(dir, vol_string) && (strstr(dest, vol_string) == NULL)){
+ char temp[buf_length];
+ strlcpy(temp, dest, buf_length);
+ snprintf(dest, buf_length, "%s%s", vol_string, temp);
+ }
+#endif
return 0;
}
@@ -3451,7 +3463,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
/* use current working directory as base for pathname */
if (format_track_path(path, filename, sizeof(tmp_buf),
- strlen(filename)+1, getcwd(NULL, -1)) < 0)
+ strlen(filename)+1, '/') < 0)
return -1;
/* can ignore volatile here, because core_get_data() is called later */