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

Stefano Sabatini stefasab at gmail.com
Fri Jan 3 18:12:44 CET 2014


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 (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.
-- 
FFmpeg = Frenzy and Fierce Minimalistic Picky Ecumenical Geisha


More information about the ffmpeg-devel mailing list