[FFmpeg-cvslog] lavf/file: file_check: Handle file URLs that start with "file:"
Alexander Strasser
git at videolan.org
Sun Jan 5 00:07:31 CET 2014
ffmpeg | branch: master | Alexander Strasser <eclipse7 at gmx.net> | Thu Jan 2 19:00:15 2014 +0100| [77015443a84bb5dbed38eafc2ea26a2bf2641ed6] | committer: Alexander Strasser
lavf/file: file_check: Handle file URLs that start with "file:"
Handle the URL analog to file_open, it may contain a "file:"
prefix. Skip it. Make access checks to file URLs starting
with "file:" work.
Fix part of ticket #3249.
Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77015443a84bb5dbed38eafc2ea26a2bf2641ed6
---
libavformat/file.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/libavformat/file.c b/libavformat/file.c
index 2defc75..1d323e2 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;
+ av_strstart(filename, "file:", &filename);
+
+ {
+#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);
+ 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;
}
More information about the ffmpeg-cvslog
mailing list