summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMariusz SzczepaƄczyk <mszczepanczyk@gmail.com>2015-06-17 20:12:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-22 12:46:08 +0200
commit80e18bb4868a3e95e49b98bcabff25607e1b9679 (patch)
tree68051af4c9d956b036be7615562b1d4e257da90a /libavformat
parent8fb672b50ae3c5faf75889a2ed8a867af0ddc8a8 (diff)
lavf/avio: Extend API with avio_move() and avio_delete()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avio.c38
-rw-r--r--libavformat/avio.h19
-rw-r--r--libavformat/url.h2
-rw-r--r--libavformat/version.h2
4 files changed, 60 insertions, 1 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 261ff2af98..bd329446e3 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -421,6 +421,44 @@ int avio_check(const char *url, int flags)
return ret;
}
+int avio_move(const char *url_src, const char *url_dst)
+{
+ URLContext *h_src, *h_dst;
+ int ret = ffurl_alloc(&h_src, url_src, AVIO_FLAG_READ_WRITE, NULL);
+ if (ret < 0)
+ return ret;
+ ret = ffurl_alloc(&h_dst, url_dst, AVIO_FLAG_WRITE, NULL);
+ if (ret < 0) {
+ ffurl_close(h_src);
+ return ret;
+ }
+
+ if (h_src->prot == h_dst->prot && h_src->prot->url_move)
+ ret = h_src->prot->url_move(h_src, h_dst);
+ else
+ ret = AVERROR(ENOSYS);
+
+ ffurl_close(h_src);
+ ffurl_close(h_dst);
+ return ret;
+}
+
+int avio_delete(const char *url)
+{
+ URLContext *h;
+ int ret = ffurl_alloc(&h, url, AVIO_FLAG_WRITE, NULL);
+ if (ret < 0)
+ return ret;
+
+ if (h->prot->url_delete)
+ ret = h->prot->url_delete(h);
+ else
+ ret = AVERROR(ENOSYS);
+
+ ffurl_close(h);
+ return ret;
+}
+
int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options)
{
URLContext *h = NULL;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 9f3a992307..5ac5d38568 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -230,6 +230,25 @@ const char *avio_find_protocol_name(const char *url);
int avio_check(const char *url, int flags);
/**
+ * Move or rename a resource.
+ *
+ * @note url_src and url_dst should share the same protocol and authority.
+ *
+ * @param url_src url to resource to be moved
+ * @param url_dst new url to resource if the operation succeeded
+ * @return >=0 on success or negative on error.
+ */
+int avio_move(const char *url_src, const char *url_dst);
+
+/**
+ * Delete a resource.
+ *
+ * @param url resource to be deleted.
+ * @return >=0 on success or negative on error.
+ */
+int avio_delete(const char *url);
+
+/**
* Open directory for reading.
*
* @param s directory read context. Pointer to a NULL pointer must be passed.
diff --git a/libavformat/url.h b/libavformat/url.h
index 1a845b77e7..99a3201cf6 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -90,6 +90,8 @@ typedef struct URLProtocol {
int (*url_open_dir)(URLContext *h);
int (*url_read_dir)(URLContext *h, AVIODirEntry **next);
int (*url_close_dir)(URLContext *h);
+ int (*url_delete)(URLContext *h);
+ int (*url_move)(URLContext *h_src, URLContext *h_dst);
} URLProtocol;
/**
diff --git a/libavformat/version.h b/libavformat/version.h
index 99b71906ba..ec84570b8b 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR 37
+#define LIBAVFORMAT_VERSION_MINOR 38
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \