summaryrefslogtreecommitdiffstats
path: root/playtreeparser.c
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-07 03:59:58 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-07 03:59:58 +0000
commit4d996f37463fd6dc88a75ffe6111482e82460923 (patch)
tree53ab493aca19279a17bee3d1ad948152dfdc2027 /playtreeparser.c
parentf7ea03283ee30d1a583ae6d425cd3908c8723a7a (diff)
downloadmpv-4d996f37463fd6dc88a75ffe6111482e82460923.tar.bz2
mpv-4d996f37463fd6dc88a75ffe6111482e82460923.tar.xz
Relative filename in playlist are now relative to the playlist path
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6663 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'playtreeparser.c')
-rw-r--r--playtreeparser.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/playtreeparser.c b/playtreeparser.c
index 903a141dc2..02848f15e2 100644
--- a/playtreeparser.c
+++ b/playtreeparser.c
@@ -16,6 +16,13 @@
#include "libmpdemux/stream.h"
#include "mp_msg.h"
+
+#if defined(__CYGWIN__) || defined(__OS2__)
+#define PATH_SEP '\\'
+#else
+#define PATH_SEP '/'
+#endif
+
extern play_tree_t*
asx_parser_build_tree(char* buffer, int ref);
@@ -412,6 +419,30 @@ parse_playtree(stream_t *stream) {
return ret;
}
+static void
+play_tree_add_basepath(play_tree_t* pt, char* bp) {
+ int i,bl = strlen(bp),fl;
+
+ if(pt->child) {
+ play_tree_t* i;
+ for(i = pt->child ; i != NULL ; i = i->next)
+ play_tree_add_basepath(i,bp);
+ return;
+ }
+
+ if(!pt->files)
+ return;
+
+ for(i = 0 ; pt->files[i] != NULL ; i++) {
+ fl = strlen(pt->files[i]);
+ if(fl <= 0 || pt->files[i][0] == PATH_SEP)
+ continue;
+ pt->files[i] = (char*)realloc(pt->files[i],bl+fl+1);
+ memmove(pt->files[i] + bl,pt->files[i],fl+1);
+ memcpy(pt->files[i],bp,bl);
+ }
+}
+
play_tree_t*
parse_playlist_file(char* file) {
stream_t *stream;
@@ -436,6 +467,14 @@ parse_playlist_file(char* file) {
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Warning error while closing playlist file %s : %s\n",file,strerror(errno));
free_stream(stream);
+ if(ret) {
+ char* ls = strrchr(file,PATH_SEP);
+ if(ls) {
+ ls[1] = '\0';
+ play_tree_add_basepath(ret,file);
+ }
+ }
+
return ret;
}