From af6ceba2a3b857ca03d1db548830e29d478ee788 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 1 Aug 2002 11:37:26 +0000 Subject: support for relative paths in playlists by Brian King git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1506 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 142f70e863..622750f5c3 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -42,6 +42,8 @@ char* playlist_next(int steps, char *dirname) int fd; int i; char buf[MAX_PATH+1]; + char dir_buf[MAX_PATH+1]; + char *dir_end; playlist.index = (playlist.index+steps) % playlist.amount; seek = playlist.indices[playlist.index]; @@ -81,10 +83,32 @@ char* playlist_next(int steps, char *dirname) strcpy(now_playing, &buf[2]); return now_playing; } - else { - snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf); + else if ( '.' == buf[0] && '.' == buf[1] && '/' == buf[2] ) { + /* handle relative paths */ + seek=3; + while(buf[seek] == '.' && + buf[seek+1] == '.' && + buf[seek+2] == '/') + seek += 3; + strcpy(dir_buf, dirname); + for (i=0; i