[FFmpeg-devel] [PATCH 3/3] ffmpeg_opt: assert_file_overwrite: Work for all file access

Alexander Strasser eclipse7 at gmx.net
Fri Jan 3 22:02:48 CET 2014


On 2014-01-03 18:12 +0100, Stefano Sabatini wrote:
> On date Thursday 2014-01-02 20:23:03 +0100, Alexander Strasser encoded:
> > Currently the file overwrite check does not work for paths that
> > contain a colon.
> > 
> > Use avio_check_if_protocol to always execute the check if the
> > file protocol is used.
> > 
> > Fix other part of ticket #3249.
> > 
> > Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> > ---
> >  ffmpeg_opt.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> > index d267c6d..3d64fbe 100644
> > --- a/ffmpeg_opt.c
> > +++ b/ffmpeg_opt.c
> > @@ -697,10 +697,7 @@ static void assert_file_overwrite(const char *filename)
> >          exit_program(1);
> >      }
> >  
> > -    if (!file_overwrite &&
> > -        (strchr(filename, ':') == NULL || filename[1] == ':' ||
> > -         av_strstart(filename, "file:", NULL))) {
> > -        if (avio_check(filename, 0) == 0) {
> 
> > +    if (!file_overwrite && !avio_check_if_protocol("file", filename, 0)) {
> >              if (stdin_interaction && !no_file_overwrite) {
> >                  fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
> >                  fflush(stderr);
> > @@ -716,7 +713,6 @@ static void assert_file_overwrite(const char *filename)
> >                  av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
> >                  exit_program(1);
> >              }
> > -        }
> >      }
> 
> I think avio_check_if_protocol() seems a bit overspecialized

  Yes, I agree. It looks not *that* useful in general. I am not
sure the old avio_check is really useful. At least I do not know
of any use cases, considering it is insufficient for the use case
in ffmpeg.

  This is why I had the impression the avio_check_if_protocol would
provide an actually useful alternative to avio_check . Though ATM
I would prefer a solution like the one you suggest below.

> (but I
> can't easily see a more elegant solution). Probably we could have a
> function like:
> 
> av_guess_url_protocol(url)
> 
> which returns the name of the protocol.

  I had a similar though when I started out, but dropped it for some
reason. Thanks for the idea, will try if I can come up with something.

  Alexander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140103/4742d1d4/attachment.asc>


More information about the ffmpeg-devel mailing list