summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-08-01 11:37:26 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-08-01 11:37:26 +0000
commitaf6ceba2a3b857ca03d1db548830e29d478ee788 (patch)
tree638dcf0724fbfdf15de9b08db2c92248ad3973d7
parente71fcaa59f5725849febf46dd2720eb4dc94d848 (diff)
downloadrockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.zip
rockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.tar.gz
rockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.tar.bz2
rockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.tar.xz
support for relative paths in playlists by Brian King <brking@charter.net>
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1506 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 142f70e..622750f 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<seek/3; i++) {
+ dir_end = strrchr(dir_buf, '/');
+ if (dir_end)
+ *dir_end = '\0';
+ else
+ break;
+ }
+ snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[seek]);
return now_playing;
}
+ else if ( '.' == buf[0] && '/' == buf[1] ) {
+ snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, &buf[2]);
+ return now_playing;
+ }
+ else {
+ snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf);
+ return now_playing;
+ }
}
}
else