diff options
author | cboesch <cboesch@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-11-16 21:06:52 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-12-16 03:59:37 +0200 |
commit | e8757fb88311329a35d874b43ff1aaf095ed4147 (patch) | |
tree | d8818a6042537bcc393f368349a2303c6fdcca52 /path.c | |
parent | 970d02c79189ce1c0037fac80bde93f0fa0cb693 (diff) | |
download | mpv-e8757fb88311329a35d874b43ff1aaf095ed4147.tar.bz2 mpv-e8757fb88311329a35d874b43ff1aaf095ed4147.tar.xz |
path.c: add function for mp_basename, remove duplicated macros
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32630 b3059339-0415-0410-9bf9-f77b7e298cf2
Fix crash on path without directories.
Regression introduced in r32630. Patch by Yuriy Kaminskiy yumkam at mail ru.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32631 b3059339-0415-0410-9bf9-f77b7e298cf2
Handle correctly paths with mixed '/' and '\' in it.
Patch by Yuriy Kaminskiy (yumkam at mail ru)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32632 b3059339-0415-0410-9bf9-f77b7e298cf2
Handle ':' on systems with DOS paths: it allows paths like C:foo.avi.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32642 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -193,3 +193,19 @@ void set_codec_path(const char *path) strcpy(codec_path, path); needs_free = 1; } + +const char *mp_basename(const char *path) +{ + char *s; + +#if HAVE_DOS_PATHS + s = strrchr(path, '\\'); + if (s) + path = s + 1; + s = strrchr(path, ':'); + if (s) + path = s + 1; +#endif + s = strrchr(path, '/'); + return s ? s + 1 : path; +} |