[FFmpeg-devel] [PATCH 1/2] avutil: add av_fopen_utf8()
Michael Niedermayer
michaelni at gmx.at
Sat Nov 2 01:06:05 CET 2013
On Fri, Nov 01, 2013 at 03:58:42AM -0300, James Almer wrote:
> On 31/10/13 10:06 PM, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> > libavutil/avutil.h | 6 ++++++
> > libavutil/file_open.c | 30 ++++++++++++++++++++++++++++++
> > 2 files changed, 36 insertions(+)
> >
> > diff --git a/libavutil/avutil.h b/libavutil/avutil.h
> > index 4692c00..7bd76d1 100644
> > --- a/libavutil/avutil.h
> > +++ b/libavutil/avutil.h
> > @@ -313,6 +313,12 @@ unsigned av_int_list_length_for_size(unsigned elsize,
> > av_int_list_length_for_size(sizeof(*(list)), list, term)
> >
> > /**
> > + * Open a file using a utf8 filename
> > + */
> > +FILE *av_fopen_utf8(const char *path, const char *mode);
> > +
> > +
>
> Nit: Drop the extra empty line.
>
> > +/**
> > * @}
> > * @}
> > */
> > diff --git a/libavutil/file_open.c b/libavutil/file_open.c
> > index 389076f..76b0852 100644
> > --- a/libavutil/file_open.c
> > +++ b/libavutil/file_open.c
> > @@ -93,3 +93,33 @@ 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 : 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)
> > + return NULL;
> > + m++;
> > + }
> > + fd = avpriv_open(path, access, 0666);
> > + if (fd == -1)
> > + return NULL;
> > + return fdopen(fd, mode);
> > +}
> > \ No newline at end of file
>
> This should probably not happen.
both fixed
>
> >
>
> Applied both patches and tested on Win7, and the examples in the ticket
> now work as intended.
thanks!
>
> Regards.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131102/f467c40b/attachment.asc>
More information about the ffmpeg-devel
mailing list