[Mplayer-cvslog] CVS: main playtreeparser.c,1.11,1.12
Alban Bedel CVS
albeu at mplayerhq.hu
Sun Jul 7 06:00:00 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv5698
Modified Files:
playtreeparser.c
Log Message:
Relative filename in playlist are now relative to the playlist path
Index: playtreeparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/playtreeparser.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- playtreeparser.c 7 Jul 2002 00:00:04 -0000 1.11
+++ playtreeparser.c 7 Jul 2002 03:59:58 -0000 1.12
@@ -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 @@
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;
@@ -435,6 +466,14 @@
if(close(fd) < 0)
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;
More information about the MPlayer-cvslog
mailing list