summaryrefslogtreecommitdiffstats
path: root/path.c
diff options
context:
space:
mode:
authorcboesch <cboesch@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-11-16 21:06:52 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-16 03:59:37 +0200
commite8757fb88311329a35d874b43ff1aaf095ed4147 (patch)
treed8818a6042537bcc393f368349a2303c6fdcca52 /path.c
parent970d02c79189ce1c0037fac80bde93f0fa0cb693 (diff)
downloadmpv-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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/path.c b/path.c
index 2a1d504ce3..7f4ce88f17 100644
--- a/path.c
+++ b/path.c
@@ -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;
+}