[FFmpeg-cvslog] lavf/libsmbclient: implement move and delete callbacks

Mariusz Szczepańczyk git at videolan.org
Wed Jun 24 00:34:07 CEST 2015


ffmpeg | branch: master | Mariusz Szczepańczyk <mszczepanczyk at gmail.com> | Mon Jun 22 04:58:00 2015 +0200| [71034163acbb5407ab72cbf71fd23ba346bb1bda] | committer: Michael Niedermayer

lavf/libsmbclient: implement move and delete callbacks

Reviewed-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71034163acbb5407ab72cbf71fd23ba346bb1bda
---

 libavformat/libsmbclient.c |   63 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/libavformat/libsmbclient.c b/libavformat/libsmbclient.c
index 1af8163..84fef7f 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,



More information about the ffmpeg-cvslog mailing list