[FFmpeg-devel] [PATCH 1/3] lavf/file: file_check: Handle paths that start with file:
Stefano Sabatini
stefasab at gmail.com
Fri Jan 3 17:35:10 CET 2014
Subject nit: lavf/file: file_check: handle paths that start with "file:"
Also you should tell how this is handling it.
On date Thursday 2014-01-02 20:21:23 +0100, Alexander Strasser encoded:
> Fix part of ticket #3249.
>
> TODO: file_check is also used in pipe protocol,
> but this patch should not hurt AFAICT
>
> Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> ---
> libavformat/file.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/file.c b/libavformat/file.c
> index 2defc75..acae281 100644
> --- a/libavformat/file.c
> +++ b/libavformat/file.c
> @@ -104,25 +104,30 @@ static int file_get_handle(URLContext *h)
>
> static int file_check(URLContext *h, int mask)
> {
> -#if HAVE_ACCESS && defined(R_OK)
> int ret = 0;
> - if (access(h->filename, F_OK) < 0)
> + const char * filename = h->filename;
nit: const char *filename = ...
> + av_strstart(filename, "file:", &filename);
So basically this is stripping "file:" from the filename. I'm not sure
it is correct to mangle the provided input file (the prefix should be
already stripped by the framework code). What happens for example if
the file starts with "file:"?
> +
> + {
Why this?
> +#if HAVE_ACCESS && defined(R_OK)
> + if (access(filename, F_OK) < 0)
> return AVERROR(errno);
> if (mask&AVIO_FLAG_READ)
> - if (access(h->filename, R_OK) >= 0)
> + if (access(filename, R_OK) >= 0)
> ret |= AVIO_FLAG_READ;
> if (mask&AVIO_FLAG_WRITE)
> - if (access(h->filename, W_OK) >= 0)
> + if (access(filename, W_OK) >= 0)
> ret |= AVIO_FLAG_WRITE;
> #else
> struct stat st;
> - int ret = stat(h->filename, &st);
> + int ret = stat(filename, &st);
> if (ret < 0)
> return AVERROR(errno);
>
> ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
> ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
> #endif
> + }
> return ret;
> }
>
> --
--
FFmpeg = Fast & Frenzy Mastering Prodigious Elitist Gargoyle
More information about the ffmpeg-devel
mailing list