fopen() on windows uses UTF-16, we use UTF-8 everywhere, this function bridges the gap by using avpriv_open()
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 18 | +2013-11-04 - xxxxxxx - lavu 52.50.100 - avutil.h | |
| 19 | + Add av_fopen_utf8() | |
| 20 | + | |
| 18 | 21 | 2013-08-xx - xxxxxxx - lavu 52.17.0 - avframe.h |
| 19 | 22 | Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT. |
| 20 | 23 | |
| @@ -312,6 +312,13 @@ unsigned av_int_list_length_for_size(unsigned elsize, · 311 unmodified lines | ||
| 312 | 312 | #define av_int_list_length(list, term) \ |
| 313 | 313 | av_int_list_length_for_size(sizeof(*(list)), list, term) |
| 314 | 314 | |
| 315 | +/** | |
| 316 | + * Open a file using a UTF-8 filename. | |
| 317 | + * The API of this function matches POSIX fopen(), errors are returned through | |
| 318 | + * errno. | |
| 319 | + */ | |
| 320 | +FILE *av_fopen_utf8(const char *path, const char *mode); | |
| 321 | + | |
| 315 | 322 | /** |
| 316 | 323 | * @} |
| 317 | 324 | * @} |
| @@ -93,3 +93,37 @@ int avpriv_open(const char *filename, int flags, ...) · 92 unmodified lines | ||
| 93 | 93 | |
| 94 | 94 | return fd; |
| 95 | 95 | } |
| 96 | + | |
| 97 | +FILE *av_fopen_utf8(const char *path, const char *mode) | |
| 98 | +{ | |
| 99 | + int fd; | |
| 100 | + int access; | |
| 101 | + const char *m = mode; | |
| 102 | + | |
| 103 | + switch (*m++) { | |
| 104 | + case 'r': access = O_RDONLY; break; | |
| 105 | + case 'w': access = O_CREAT|O_WRONLY|O_TRUNC; break; | |
| 106 | + case 'a': access = O_CREAT|O_WRONLY|O_APPEND; break; | |
| 107 | + default : | |
| 108 | + errno = EINVAL; | |
| 109 | + return NULL; | |
| 110 | + } | |
| 111 | + while (*m) { | |
| 112 | + if (*m == '+') { | |
| 113 | + access &= ~(O_RDONLY | O_WRONLY); | |
| 114 | + access |= O_RDWR; | |
| 115 | + } else if (*m == 'b') { | |
| 116 | +#ifdef O_BINARY | |
| 117 | + access |= O_BINARY; | |
| 118 | +#endif | |
| 119 | + } else if (*m) { | |
| 120 | + errno = EINVAL; | |
| 121 | + return NULL; | |
| 122 | + } | |
| 123 | + m++; | |
| 124 | + } | |
| 125 | + fd = avpriv_open(path, access, 0666); | |
| 126 | + if (fd == -1) | |
| 127 | + return NULL; | |
| 128 | + return fdopen(fd, mode); | |
| 129 | +} | |
| @@ -75,7 +75,7 @@ · 74 unmodified lines | ||
| 75 | 75 | */ |
| 76 | 76 | |
| 77 | 77 | #define LIBAVUTIL_VERSION_MAJOR 52 |
| 78 | −#define LIBAVUTIL_VERSION_MINOR 49 | |
| 78 | +#define LIBAVUTIL_VERSION_MINOR 50 | |
| 79 | 79 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 80 | 80 | |
| 81 | 81 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |