summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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