[FFmpeg-devel] [PATCH 2/3] Implement url_check() in the file and pipe protocols.
Stefano Sabatini
stefano.sabatini-lala
Thu Sep 30 17:46:00 CEST 2010
---
libavformat/file.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/libavformat/file.c b/libavformat/file.c
index 3c3f42f..ba6037d 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -94,6 +94,16 @@ static int file_close(URLContext *h)
return close(fd);
}
+static int file_check(URLContext *h, int flags)
+{
+ struct stat st;
+ int ret = stat(h->filename, &st);
+ if (ret < 0)
+ return AVERROR(errno);
+
+ return !!(st.st_mode & flags);
+}
+
URLProtocol file_protocol = {
"file",
file_open,
@@ -102,6 +112,7 @@ URLProtocol file_protocol = {
file_seek,
file_close,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_FILE_PROTOCOL */
@@ -136,6 +147,7 @@ URLProtocol pipe_protocol = {
file_read,
file_write,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_PIPE_PROTOCOL */
--
1.7.1
More information about the ffmpeg-devel
mailing list