diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-04-09 05:14:55 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-04-20 04:22:52 +0300 |
commit | bdfdece245b5aa863b4c57996c38b5638d7797d0 (patch) | |
tree | 3036399e13ea08cc44019d1e7208295f47226865 /sub/find_subfiles.c | |
parent | 7221e28fe3d743aaf6357bb0838e762781644f0d (diff) | |
download | mpv-bdfdece245b5aa863b4c57996c38b5638d7797d0.tar.bz2 mpv-bdfdece245b5aa863b4c57996c38b5638d7797d0.tar.xz |
subs: move vobsub loading logic down to find_subfiles.c
Analogously to the previous commit, move path handling logic for
loading external vobsub files from mplayer.c to find_subfiles.c.
Based on a commit from Clément Bœsch but fixed and simplified.
Diffstat (limited to 'sub/find_subfiles.c')
-rw-r--r-- | sub/find_subfiles.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 19ee0f065b..862afe53c6 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -5,6 +5,7 @@ #include "mp_msg.h" #include "path.h" +#include "mpcommon.h" #include "sub/find_subfiles.h" #include "sub/sub.h" @@ -278,3 +279,27 @@ char **find_text_subtitles(const char *fname) free(psub); return tmp; } + +char **find_vob_subtitles(const char *fname) +{ + char **vobs = talloc_array_ptrtype(NULL, vobs, 1); + int n = 0; + + // Potential vobsub in the media directory + struct bstr bname = BSTR(mp_basename(fname)); + int pdot = bstrrchr(bname, '.'); + if (pdot >= 0) + bname.len = pdot; + vobs[n++] = mp_path_join(vobs, mp_dirname(fname), bname); + + // Potential vobsub in ~/.mplayer/sub + char *mp_subdir = get_path("sub/"); + if (mp_subdir) { + MP_GROW_ARRAY(vobs, n); + vobs[n++] = mp_path_join(vobs, BSTR(mp_subdir), bname); + } + + free(mp_subdir); + MP_RESIZE_ARRAY(NULL, vobs, n); + return vobs; +} |