[FFmpeg-devel] [PATCH 3/9] lavf/file: implement EXCL flag.

wm4 nfxjfg at googlemail.com
Sat Apr 19 09:06:18 CEST 2014


On Sat, 19 Apr 2014 08:44:27 +0200
Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:

> On 16.04.2014, at 18:58, Nicolas George <george at nsup.org> wrote:
> > 
> > Signed-off-by: Nicolas George <george at nsup.org>
> > ---
> > libavformat/file.c |    7 +++++++
> > 1 file changed, 7 insertions(+)
> > 
> > diff --git a/libavformat/file.c b/libavformat/file.c
> > index 6511328..89437c7 100644
> > --- a/libavformat/file.c
> > +++ b/libavformat/file.c
> > @@ -153,6 +153,10 @@ static int file_open(URLContext *h, const char *filename, int flags)
> >     } else {
> >         access = O_RDONLY;
> >     }
> > +#ifdef O_EXCL
> > +    if ((access & O_CREAT) && (flags & AVIO_FLAG_EXCL))
> > +        access |= O_EXCL;
> > +#endif
> 
> Sorry for being too lazy to check the source, but maybe you know it:
> Will this work on Windows?
> If no, should we implement it?
> If yes, isn't it confusing to default to non-exclusive even though the whole OS defaults to exclusive?

AFAIK O_EXCL is about atomically creating and opening the file, so that
you never open an existing. And I think Windows' open() defaults to
normal semantics, but doesn't have O_EXCL, so with this implementation
AVIO_FLAG_EXCL won't work on Windows.

CreateFile seems to support this with CREATE_NEW, so it's all just a
problem with MSVCRT being essentially unmaintained. But it seems MingGW
provides a proper open() implementation which emulates this flag.


More information about the ffmpeg-devel mailing list