History

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()

Michael Niedermayer committed 13 years ago

Commit 85cabf11 parent d0ac6074 files · +45 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/avutil.h +7 −0
  3. libavutil/file_open.c +34 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182013-11-04 - xxxxxxx - lavu 52.50.100 - avutil.h
19 Add av_fopen_utf8()
20
182013-08-xx - xxxxxxx - lavu 52.17.0 - avframe.h212013-08-xx - xxxxxxx - lavu 52.17.0 - avframe.h
19 Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT.22 Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT.
20 23
libavutil/avutil.h+7−0
@@ -312,6 +312,13 @@ unsigned av_int_list_length_for_size(unsigned elsize, · 311 unmodified lines
312#define av_int_list_length(list, term) \312#define av_int_list_length(list, term) \
313 av_int_list_length_for_size(sizeof(*(list)), list, term)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 */
320FILE *av_fopen_utf8(const char *path, const char *mode);
321
315/**322/**
316 * @}323 * @}
317 * @}324 * @}
libavutil/file_open.c+34−0
@@ -93,3 +93,37 @@ int avpriv_open(const char *filename, int flags, ...) · 92 unmodified lines
93 93
94 return fd;94 return fd;
95}95}
96
97FILE *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}
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
75 */75 */
76 76
77#define LIBAVUTIL_VERSION_MAJOR 5277#define LIBAVUTIL_VERSION_MAJOR 52
78#define LIBAVUTIL_VERSION_MINOR 4978#define LIBAVUTIL_VERSION_MINOR 50
79#define LIBAVUTIL_VERSION_MICRO 10079#define LIBAVUTIL_VERSION_MICRO 100
80 80
81#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \81#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t