summaryrefslogtreecommitdiff
path: root/apps/playlist.c
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 /apps/playlist.c
parente71fcaa59f5725849febf46dd2720eb4dc94d848 (diff)
downloadrockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.tar.gz
rockbox-af6ceba2a3b857ca03d1db548830e29d478ee788.zip
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
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c28
1 files 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)
42 int fd; 42 int fd;
43 int i; 43 int i;
44 char buf[MAX_PATH+1]; 44 char buf[MAX_PATH+1];
45 char dir_buf[MAX_PATH+1];
46 char *dir_end;
45 47
46 playlist.index = (playlist.index+steps) % playlist.amount; 48 playlist.index = (playlist.index+steps) % playlist.amount;
47 seek = playlist.indices[playlist.index]; 49 seek = playlist.indices[playlist.index];
@@ -81,10 +83,32 @@ char* playlist_next(int steps, char *dirname)
81 strcpy(now_playing, &buf[2]); 83 strcpy(now_playing, &buf[2]);
82 return now_playing; 84 return now_playing;
83 } 85 }
84 else { 86 else if ( '.' == buf[0] && '.' == buf[1] && '/' == buf[2] ) {
85 snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf); 87 /* handle relative paths */
88 seek=3;
89 while(buf[seek] == '.' &&
90 buf[seek+1] == '.' &&
91 buf[seek+2] == '/')
92 seek += 3;
93 strcpy(dir_buf, dirname);
94 for (i=0; i<seek/3; i++) {
95 dir_end = strrchr(dir_buf, '/');
96 if (dir_end)
97 *dir_end = '\0';
98 else
99 break;
100 }
101 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[seek]);
86 return now_playing; 102 return now_playing;
87 } 103 }
104 else if ( '.' == buf[0] && '/' == buf[1] ) {
105 snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, &buf[2]);
106 return now_playing;
107 }
108 else {
109 snprintf(now_playing, MAX_PATH+1, "%s/%s", dirname, buf);
110 return now_playing;
111 }
88 } 112 }
89 } 113 }
90 else 114 else