diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-12-30 13:54:50 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-12-30 13:54:50 +0100 |
commit | 2ce43b37fc46e3744d9d5e1baa1280c48ef7b1bf (patch) | |
tree | 24ca5287a90069a324ee49ad251f0d9a69ca0aea /libavutil/avstring.c | |
parent | 613001d75fee9dfef14fb000cac8c67ac6381e97 (diff) | |
parent | 6dd93ee6f1b050ad7c4b247899e83efa293ee405 (diff) | |
download | ffmpeg-2ce43b37fc46e3744d9d5e1baa1280c48ef7b1bf.tar.gz |
Merge commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405'
* commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405':
hlsenc: check append_entry return value
hlsenc: use the basename to generate the list entries
avstring: add av_basename and av_dirname
Conflicts:
Changelog
doc/APIchanges
libavutil/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/avstring.c')
-rw-r--r-- | libavutil/avstring.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libavutil/avstring.c b/libavutil/avstring.c index f03df67441..7072a55cf3 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -25,6 +25,8 @@ #include <string.h> #include <ctype.h> #include "avstring.h" +#include "config.h" +#include "common.h" #include "mem.h" int av_strstart(const char *str, const char *pfx, const char **ptr) @@ -211,6 +213,45 @@ int av_strncasecmp(const char *a, const char *b, size_t n) return c1 - c2; } +const char *av_basename(const char *path) +{ + char *p = strrchr(path, '/'); + +#if HAVE_DOS_PATHS + char *q = strrchr(path, '\\'); + char *d = strchr(path, ':'); + + p = FFMAX3(p, q, d); +#endif + + if (!p) + return path; + + return p + 1; +} + +const char *av_dirname(char *path) +{ + char *p = strrchr(path, '/'); + +#if HAVE_DOS_PATHS + char *q = strrchr(path, '\\'); + char *d = strchr(path, ':'); + + d = d ? d + 1 : d; + + p = FFMAX3(p, q, d); +#endif + + if (!p) + return "."; + + *p = '\0'; + + return path; +} + + #ifdef TEST #include "common.h" |