Change some filename-handling code to use mp_basename()

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32675 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
cboesch 2010-12-04 10:24:42 +00:00 committed by Uoti Urpala
parent 9e35edf08b
commit 920d0976e7
3 changed files with 8 additions and 35 deletions

View File

@ -290,10 +290,8 @@ static int mp_property_filename(m_option_t *prop, int action, void *arg,
char *f;
if (!mpctx->filename)
return M_PROPERTY_UNAVAILABLE;
if (((f = strrchr(mpctx->filename, '/'))
|| (f = strrchr(mpctx->filename, '\\'))) && f[1])
f++;
else
f = (char *)mp_basename(mpctx->filename);
if (!*f)
f = mpctx->filename;
return m_property_string_ro(prop, action, arg, f);
}
@ -1523,10 +1521,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
sub_name = ass_track->name;
#endif
if (sub_name) {
char *tmp, *tmp2;
tmp = sub_name;
if ((tmp2 = strrchr(tmp, '/')))
tmp = tmp2 + 1;
const char *tmp = mp_basename(sub_name);
snprintf(*(char **) arg, 63, "(%d) %s%s",
mpctx->set_of_sub_pos + 1,

View File

@ -1013,7 +1013,7 @@ static void load_per_file_config (m_config_t* conf, const char *const file)
{
char *confpath;
char cfg[PATH_MAX];
char *name;
const char *name;
if (strlen(file) > PATH_MAX - 14) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, can not load file or directory specific config files\n");
@ -1021,20 +1021,7 @@ static void load_per_file_config (m_config_t* conf, const char *const file)
}
sprintf (cfg, "%s.conf", file);
name = strrchr(cfg, '/');
if (HAVE_DOS_PATHS) {
char *tmp = strrchr(cfg, '\\');
if (!name || tmp > name)
name = tmp;
tmp = strrchr(cfg, ':');
if (!name || tmp > name)
name = tmp;
}
if (!name)
name = cfg;
else
name++;
name = mp_basename(cfg);
if (use_filedir_conf) {
char dircfg[PATH_MAX];
strcpy(dircfg, cfg);
@ -3695,14 +3682,8 @@ if (edl_output_filename) {
vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec);
/* try from ~/.mplayer/sub */
if(!vo_vobsub && (psub = get_path( "sub/" ))) {
char *bname;
const char *bname = mp_basename(buf);
int l;
bname = strrchr(buf,'/');
#if defined(__MINGW32__) || defined(__CYGWIN__)
if(!bname) bname = strrchr(buf,'\\');
#endif
if(bname) bname++;
else bname = buf;
l = strlen(psub) + strlen(bname) + 1;
psub = realloc(psub,l);
strcat(psub,bname);

View File

@ -36,6 +36,7 @@
#include "vobsub.h"
#include "spudec.h"
#include "mp_msg.h"
#include "path.h"
#include "unrar_exec.h"
#include "libavutil/common.h"
@ -96,11 +97,7 @@ static rar_stream_t *rar_open(const char *const filename,
strcat(rar_filename, ".rar");
}
/* get rid of the path if there is any */
if ((p = strrchr(filename, '/')) == NULL) {
p = filename;
} else {
p++;
}
p = mp_basename(filename);
rc = unrar_exec_get(&stream->data, &stream->size, p, rar_filename);
if (!rc) {
/* There is no matching filename in the archive. However, sometimes