[FFmpeg-cvslog] file: implement url_check() callback in the file and pipe protocols

Stefano Sabatini git at videolan.org
Thu Apr 14 03:24:36 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Thu Sep 30 13:21:42 2010 +0200| [313176565cf813a1a9cd5b8bc3f59c0b9696390e] | committer: Anton Khirnov

file: implement url_check() callback in the file and pipe protocols

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=313176565cf813a1a9cd5b8bc3f59c0b9696390e
---

 libavformat/file.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/libavformat/file.c b/libavformat/file.c
index 31067ed..1dcb2c8 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -95,6 +95,20 @@ static int file_close(URLContext *h)
     return close(fd);
 }
 
+static int file_check(URLContext *h, int mask)
+{
+    struct stat st;
+    int ret = stat(h->filename, &st);
+    if (ret < 0)
+        return AVERROR(errno);
+
+    ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0;
+    ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0;
+    ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0;
+
+    return ret;
+}
+
 URLProtocol ff_file_protocol = {
     .name                = "file",
     .url_open            = file_open,
@@ -103,6 +117,7 @@ URLProtocol ff_file_protocol = {
     .url_seek            = file_seek,
     .url_close           = file_close,
     .url_get_file_handle = file_get_handle,
+    .url_check           = file_check,
 };
 
 #endif /* CONFIG_FILE_PROTOCOL */
@@ -137,6 +152,7 @@ URLProtocol ff_pipe_protocol = {
     .url_read            = file_read,
     .url_write           = file_write,
     .url_get_file_handle = file_get_handle,
+    .url_check           = file_check,
 };
 
 #endif /* CONFIG_PIPE_PROTOCOL */



More information about the ffmpeg-cvslog mailing list