[PATCH] file: implement url_check() callback in the file and pipe protocols
Stefano Sabatini
stefano.sabatini-lala at poste.it
Thu Sep 30 13:21:42 CEST 2010
---
libavformat/file.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/libavformat/file.c b/libavformat/file.c
index b8c7c4c..f939a8e 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -94,6 +94,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 = {
"file",
file_open,
@@ -102,6 +116,7 @@ URLProtocol ff_file_protocol = {
file_seek,
file_close,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_FILE_PROTOCOL */
@@ -136,6 +151,7 @@ URLProtocol ff_pipe_protocol = {
file_read,
file_write,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_PIPE_PROTOCOL */
--
1.7.2.3
--SUOF0GtieIMvvwua
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0003-prefer-avio_check-over-url_exist.patch"
More information about the libav-devel
mailing list