123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef FFTOOLS_FOPEN_UTF8_H
- #define FFTOOLS_FOPEN_UTF8_H
- #include <stdio.h>
- #ifdef _WIN32
- #include "libavutil/mem.h"
- #include "libavutil/wchar_filename.h"
- static inline FILE *fopen_utf8(const char *path_utf8, const char *mode)
- {
- wchar_t *path_w, *mode_w;
- FILE *f;
-
- if (get_extended_win32_path(path_utf8, &path_w))
- return NULL;
- if (!path_w)
- goto fallback;
- if (utf8towchar(mode, &mode_w))
- return NULL;
- if (!mode_w) {
-
- av_freep(&path_w);
- errno = EINVAL;
- return NULL;
- }
- f = _wfopen(path_w, mode_w);
- av_freep(&path_w);
- av_freep(&mode_w);
- return f;
- fallback:
-
- return fopen(path_utf8, mode);
- }
- #else
- static inline FILE *fopen_utf8(const char *path, const char *mode)
- {
- return fopen(path, mode);
- }
- #endif
- #endif
|