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>
This commit is contained in:
parent
0c3934f917
commit
b30edcd62f
1 changed files with 13 additions and 1 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue