summaryrefslogtreecommitdiff
path: root/libavformat/avio.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-04-08 18:32:25 +0200
committerAnton Khirnov <anton@khirnov.net>2011-04-13 07:38:15 +0200
commit175389c85487822f1ee180ee01cc770df896557f (patch)
tree1fa215240c2a7c8b9eb27b2566385c4f2728c52b /libavformat/avio.c
parentcbea3ac8203690dec29c473399a50f8f6bb76c47 (diff)
avio: add avio_check()
The new function is more flexible than url_exist(), as it allows to specify which access flags to check, and does not require an explicit open of the checked resource. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/avio.c')
-rw-r--r--libavformat/avio.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index ad1f1b40c2..18b2ee6c22 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -374,6 +374,25 @@ int url_exist(const char *filename)
return 1;
}
+int avio_check(const char *url, int flags)
+{
+ URLContext *h;
+ int ret = ffurl_alloc(&h, url, flags);
+ if (ret)
+ return ret;
+
+ if (h->prot->url_check) {
+ ret = h->prot->url_check(h, flags);
+ } else {
+ ret = ffurl_connect(h);
+ if (ret >= 0)
+ ret = flags;
+ }
+
+ ffurl_close(h);
+ return ret;
+}
+
int64_t ffurl_size(URLContext *h)
{
int64_t pos, size;