summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMariusz SzczepaƄczyk <mszczepanczyk@gmail.com>2015-06-22 04:58:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-24 00:25:24 +0200
commit71034163acbb5407ab72cbf71fd23ba346bb1bda (patch)
tree1ab843e95c414edf05f9db6a928d9335739f77b3 /libavformat
parent94a43dcff1eabbaf14c80edf4b08450e69a12218 (diff)
lavf/libsmbclient: implement move and delete callbacks
Reviewed-by: Lukasz Marek <lukasz.m.luki2@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/libsmbclient.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/libavformat/libsmbclient.c b/libavformat/libsmbclient.c
index 1af8163674..84fef7f162 100644
--- a/libavformat/libsmbclient.c
+++ b/libavformat/libsmbclient.c
@@ -287,6 +287,67 @@ static int libsmbc_close_dir(URLContext *h)
return 0;
}
+static int libsmbc_delete(URLContext *h)
+{
+ LIBSMBContext *libsmbc = h->priv_data;
+ int ret;
+ struct stat st;
+
+ if ((ret = libsmbc_connect(h)) < 0)
+ goto cleanup;
+
+ if ((libsmbc->fd = smbc_open(h->filename, O_WRONLY, 0666)) < 0) {
+ ret = AVERROR(errno);
+ goto cleanup;
+ }
+
+ if (smbc_fstat(libsmbc->fd, &st) < 0) {
+ ret = AVERROR(errno);
+ goto cleanup;
+ }
+
+ smbc_close(libsmbc->fd);
+ libsmbc->fd = -1;
+
+ if (S_ISDIR(st.st_mode)) {
+ if (smbc_rmdir(h->filename) < 0) {
+ ret = AVERROR(errno);
+ goto cleanup;
+ }
+ } else {
+ if (smbc_unlink(h->filename) < 0) {
+ ret = AVERROR(errno);
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+cleanup:
+ libsmbc_close(h);
+ return ret;
+}
+
+static int libsmbc_move(URLContext *h_src, URLContext *h_dst)
+{
+ LIBSMBContext *libsmbc = h_src->priv_data;
+ int ret;
+
+ if ((ret = libsmbc_connect(h_src)) < 0)
+ goto cleanup;
+
+ if ((libsmbc->dh = smbc_rename(h_src->filename, h_dst->filename)) < 0) {
+ ret = AVERROR(errno);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ libsmbc_close(h_src);
+ return ret;
+}
+
#define OFFSET(x) offsetof(LIBSMBContext, x)
#define D AV_OPT_FLAG_DECODING_PARAM
#define E AV_OPT_FLAG_ENCODING_PARAM
@@ -311,6 +372,8 @@ URLProtocol ff_libsmbclient_protocol = {
.url_write = libsmbc_write,
.url_seek = libsmbc_seek,
.url_close = libsmbc_close,
+ .url_delete = libsmbc_delete,
+ .url_move = libsmbc_move,
.url_open_dir = libsmbc_open_dir,
.url_read_dir = libsmbc_read_dir,
.url_close_dir = libsmbc_close_dir,