diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2003-01-09 00:18:47 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2003-01-09 00:18:47 +0000 |
| commit | 0e342181c3f96890506aa8720ac2d680b97c12e4 (patch) | |
| tree | c6cfbf90f2658cf1aa97075d6322e03b20edb8d6 | |
| parent | 02e1b626b65d7aaec35abdc297c6ec726694c762 (diff) | |
| download | rockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.zip rockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.tar.gz rockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.tar.bz2 rockbox-0e342181c3f96890506aa8720ac2d680b97c12e4.tar.xz | |
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.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index ce812c7..38eca09 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -192,7 +192,6 @@ char* playlist_peek(int steps) if('/' == buf[0]) { strcpy(now_playing, &buf[0]); - return now_playing; } else { strncpy(dir_buf, playlist.filename, playlist.dirlen-1); @@ -201,7 +200,6 @@ char* playlist_peek(int steps) /* handle dos style drive letter */ if ( ':' == buf[1] ) { strcpy(now_playing, &buf[2]); - return now_playing; } else if ( '.' == buf[0] && '.' == buf[1] && '/' == buf[2] ) { /* handle relative paths */ @@ -218,17 +216,35 @@ char* playlist_peek(int steps) 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", dir_buf, &buf[2]); - return now_playing; } else { snprintf(now_playing, MAX_PATH+1, "%s/%s", dir_buf, buf); - return now_playing; } } + + buf = now_playing; + + /* remove bogus dirs from beginning of path + (workaround for buggy playlist creation tools) */ + while (buf) + { + fd = open(buf, O_RDONLY); + if (fd > 0) + { + close(fd); + break; + } + + buf = strchr(buf+1, '/'); + } + + if (buf) + return buf; + + return now_playing; } /* |