[FFmpeg-devel] url_exists function in avio.c opens instead of checking existence

Michael Niedermayer michaelni
Tue Sep 14 16:49:17 CEST 2010


On Tue, Sep 14, 2010 at 03:07:09PM +0200, Stefano Sabatini wrote:
> On date Thursday 2010-01-21 12:29:36 +0100, Stefano Sabatini encoded:
> > On date Wednesday 2010-01-20 21:24:46 +0100, Maker aka Michele encoded:
> > > > if ((ret = url_check(file, w) != AVERROR(ENOENT))  // the file exists
> > > >    ask_for_overwrite_confirmation();
> > > >
> > > > uhm, yeah, may a function like "url_check" isn't really like url_exists,
> > > but should be more useful.
> > > But my opinion is that a file shouldn't be opened if we just want to know if
> > > it is writable/readable. So, what about extending URLProtocol with a pointer
> > > to function,  which checks if the url can be opened in a certain mode
> > > (specific for each protocol)?
> > 
> > (Quick reply as I'm pretty busy now)
> > Options:
> > 
> > 1) implement url_check()
> > 
> > 2) extend url_exist() with a simple if (url == "file") then stat(...);,
> > not elegant but it should work.
> > 
> > 3) extend URLProtocol and make it implement an url_exist method() for
> > each protocol, this looks a little overkill to me.
> > 
> > I have no strong preference on these, so I'll let the decision to the
> > maintainers, in the meaningwhile you may provide a patch implementing
> > your favourite approach.
> 
> Ping. Another solution would be implementing a per protocol
> url_check() function, which checks if a "protocol stream" can be
> opened with a certain mode, and can be used for the testing if a file
> exists.
> 
> In the case of the "file" protocol it would use stat(), and should
> possibly fix the problem at hand.

you will need something per protocol yes, and there needs to be a fallback
that uses open if the protocol has no specific implementation of url_check


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100914/a55ec889/attachment.pgp>



More information about the ffmpeg-devel mailing list