From 6b91b7ea57ee2798c2b86853e4e4aa95bbb3ddaa Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Fri, 5 Jul 2002 12:48:17 +0000 Subject: Relative path playlist patch by Mat Pritchard git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1342 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'apps/playlist.c') diff --git a/apps/playlist.c b/apps/playlist.c index 4a2a6fdab2..2d8bbd3a33 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -33,14 +33,15 @@ playlist_info_t playlist; -char now_playing[256]; +char now_playing[MAX_PATH+1]; -char* playlist_next(int steps) +char* playlist_next(int steps, char *dirname) { int seek; int max; int fd; int i; + char buf[MAX_PATH+1]; playlist.index = (playlist.index+steps) % playlist.amount; seek = playlist.indices[playlist.index]; @@ -48,36 +49,40 @@ char* playlist_next(int steps) fd = open(playlist.filename, O_RDONLY); if(-1 != fd) { lseek(fd, seek, SEEK_SET); - max = read(fd, now_playing+1, sizeof(now_playing)-1); + max = read(fd, buf, sizeof(buf)-1); close(fd); /* Zero-terminate the file name */ seek=0; - while((now_playing[seek] != '\n') && - (now_playing[seek] != '\r') && + while((buf[seek] != '\n') && + (buf[seek] != '\r') && (seek < max)) seek++; /* Now work back killing white space */ - while((now_playing[seek-1] == ' ') || - (now_playing[seek-1] == '\t')) + while((buf[seek-1] == ' ') || + (buf[seek-1] == '\t')) seek--; - now_playing[seek]=0; + buf[seek]=0; /* replace backslashes with forward slashes */ for ( i=1; iindices[ playlist->amount ] = i+count; playlist->amount++; -- cgit v1.2.3