summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-01-09 00:18:47 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-01-09 00:18:47 +0000
commit0e342181c3f96890506aa8720ac2d680b97c12e4 (patch)
treec6cfbf90f2658cf1aa97075d6322e03b20edb8d6
parent02e1b626b65d7aaec35abdc297c6ec726694c762 (diff)
downloadrockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.tar.gz
rockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.zip
Remove bogus dirs from beginning of playlist file path. Patch by Hardeep Sidhu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3039 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playlist.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index ce812c7c67..38eca09fc9 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -192,7 +192,6 @@ char* playlist_peek(int steps)
192 192
193 if('/' == buf[0]) { 193 if('/' == buf[0]) {
194 strcpy(now_playing, &buf[0]); 194 strcpy(now_playing, &buf[0]);
195 return now_playing;
196 } 195 }
197 else { 196 else {
198 strncpy(dir_buf, playlist.filename, playlist.dirlen-1); 197 strncpy(dir_buf, playlist.filename, playlist.dirlen-1);
@@ -201,7 +200,6 @@ char* playlist_peek(int steps)
201 /* handle dos style drive letter */ 200 /* handle dos style drive letter */
202 if ( ':' == buf[1] ) { 201 if ( ':' == buf[1] ) {
203 strcpy(now_playing, &buf[2]); 202 strcpy(now_playing, &buf[2]);
204 return now_playing;
205 } 203 }
206 else if ( '.' == buf[0] && '.' == buf[1] && '/' == buf[2] ) { 204 else if ( '.' == buf[0] && '.' == buf[1] && '/' == buf[2] ) {
207 /* handle relative paths */ 205 /* handle relative paths */
@@ -218,17 +216,35 @@ char* playlist_peek(int steps)
218 break; 216 break;
219 } 217 }
220 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[seek]); 218 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[seek]);
221 return now_playing;
222 } 219 }
223 else if ( '.' == buf[0] && '/' == buf[1] ) { 220 else if ( '.' == buf[0] && '/' == buf[1] ) {
224 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[2]); 221 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, &buf[2]);
225 return now_playing;
226 } 222 }
227 else { 223 else {
228 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, buf); 224 snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, buf);
229 return now_playing;
230 } 225 }
231 } 226 }
227
228 buf = now_playing;
229
230 /* remove bogus dirs from beginning of path
231 (workaround for buggy playlist creation tools) */
232 while (buf)
233 {
234 fd = open(buf, O_RDONLY);
235 if (fd > 0)
236 {
237 close(fd);
238 break;
239 }
240
241 buf = strchr(buf+1, '/');
242 }
243
244 if (buf)
245 return buf;
246
247 return now_playing;
232} 248}
233 249
234/* 250/*