Mercurial > mplayer.hg
comparison playtreeparser.c @ 6662:f8e25756a5ec
Relative filename in playlist are now relative to the playlist path
author | albeu |
---|---|
date | Sun, 07 Jul 2002 03:59:58 +0000 |
parents | dc61b6b159e4 |
children | 5790a2576505 |
comparison
equal
deleted
inserted
replaced
6661:dc61b6b159e4 | 6662:f8e25756a5ec |
---|---|
13 #include <unistd.h> | 13 #include <unistd.h> |
14 #include "playtree.h" | 14 #include "playtree.h" |
15 #include "playtreeparser.h" | 15 #include "playtreeparser.h" |
16 #include "libmpdemux/stream.h" | 16 #include "libmpdemux/stream.h" |
17 #include "mp_msg.h" | 17 #include "mp_msg.h" |
18 | |
19 | |
20 #if defined(__CYGWIN__) || defined(__OS2__) | |
21 #define PATH_SEP '\\' | |
22 #else | |
23 #define PATH_SEP '/' | |
24 #endif | |
18 | 25 |
19 extern play_tree_t* | 26 extern play_tree_t* |
20 asx_parser_build_tree(char* buffer, int ref); | 27 asx_parser_build_tree(char* buffer, int ref); |
21 | 28 |
22 #define BUF_STEP 1024 | 29 #define BUF_STEP 1024 |
410 play_tree_parser_free(p); | 417 play_tree_parser_free(p); |
411 | 418 |
412 return ret; | 419 return ret; |
413 } | 420 } |
414 | 421 |
422 static void | |
423 play_tree_add_basepath(play_tree_t* pt, char* bp) { | |
424 int i,bl = strlen(bp),fl; | |
425 | |
426 if(pt->child) { | |
427 play_tree_t* i; | |
428 for(i = pt->child ; i != NULL ; i = i->next) | |
429 play_tree_add_basepath(i,bp); | |
430 return; | |
431 } | |
432 | |
433 if(!pt->files) | |
434 return; | |
435 | |
436 for(i = 0 ; pt->files[i] != NULL ; i++) { | |
437 fl = strlen(pt->files[i]); | |
438 if(fl <= 0 || pt->files[i][0] == PATH_SEP) | |
439 continue; | |
440 pt->files[i] = (char*)realloc(pt->files[i],bl+fl+1); | |
441 memmove(pt->files[i] + bl,pt->files[i],fl+1); | |
442 memcpy(pt->files[i],bp,bl); | |
443 } | |
444 } | |
445 | |
415 play_tree_t* | 446 play_tree_t* |
416 parse_playlist_file(char* file) { | 447 parse_playlist_file(char* file) { |
417 stream_t *stream; | 448 stream_t *stream; |
418 play_tree_t* ret; | 449 play_tree_t* ret; |
419 int fd; | 450 int fd; |
434 ret = parse_playtree(stream); | 465 ret = parse_playtree(stream); |
435 if(close(fd) < 0) | 466 if(close(fd) < 0) |
436 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Warning error while closing playlist file %s : %s\n",file,strerror(errno)); | 467 mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Warning error while closing playlist file %s : %s\n",file,strerror(errno)); |
437 free_stream(stream); | 468 free_stream(stream); |
438 | 469 |
470 if(ret) { | |
471 char* ls = strrchr(file,PATH_SEP); | |
472 if(ls) { | |
473 ls[1] = '\0'; | |
474 play_tree_add_basepath(ret,file); | |
475 } | |
476 } | |
477 | |
439 return ret; | 478 return ret; |
440 | 479 |
441 } | 480 } |
442 | 481 |
443 | 482 |