X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Ffile_open.c;h=bcdd26ae355410fdc5d9a6f7cedf45b9b178127d;hb=4729b529e60fb99356a1d9e13793835af50b3e87;hp=389076fca164d590975bf91253e901c8f2f8b7d2;hpb=3fc26d8073a49c96a0704015ce18f5317d87a739;p=ffmpeg diff --git a/libavutil/file_open.c b/libavutil/file_open.c index 389076fca16..bcdd26ae355 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); +}