summaryrefslogtreecommitdiffstats
path: root/libavutil/file_open.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-01 01:51:14 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-04 15:38:52 +0100
commit85cabf1ca98fcc502fcf5b8d6bfb6d8061c2caef (patch)
tree5cac6c8fcca90badb397dd816513491eebf5929c /libavutil/file_open.c
parentd0ac60730d26f1d59817c675806ed199abbef906 (diff)
downloadffmpeg-streaming-85cabf1ca98fcc502fcf5b8d6bfb6d8061c2caef.zip
ffmpeg-streaming-85cabf1ca98fcc502fcf5b8d6bfb6d8061c2caef.tar.gz
avutil: add av_fopen_utf8()
fopen() on windows uses UTF-16, we use UTF-8 everywhere, this function bridges the gap by using avpriv_open() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/file_open.c')
-rw-r--r--libavutil/file_open.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libavutil/file_open.c b/libavutil/file_open.c
index 389076f..bcdd26a 100644
--- a/libavutil/file_open.c
+++ b/libavutil/file_open.c
@@ -93,3 +93,37 @@ int avpriv_open(const char *filename, int flags, ...)
return fd;
}
+
+FILE *av_fopen_utf8(const char *path, const char *mode)
+{
+ int fd;
+ int access;
+ const char *m = mode;
+
+ switch (*m++) {
+ case 'r': access = O_RDONLY; break;
+ case 'w': access = O_CREAT|O_WRONLY|O_TRUNC; break;
+ case 'a': access = O_CREAT|O_WRONLY|O_APPEND; break;
+ default :
+ errno = EINVAL;
+ return NULL;
+ }
+ while (*m) {
+ if (*m == '+') {
+ access &= ~(O_RDONLY | O_WRONLY);
+ access |= O_RDWR;
+ } else if (*m == 'b') {
+#ifdef O_BINARY
+ access |= O_BINARY;
+#endif
+ } else if (*m) {
+ errno = EINVAL;
+ return NULL;
+ }
+ m++;
+ }
+ fd = avpriv_open(path, access, 0666);
+ if (fd == -1)
+ return NULL;
+ return fdopen(fd, mode);
+}
OpenPOWER on IntegriCloud