s4-pysmb: Add deltree() method to remove directory and its contents
authorAmitay Isaacs <amitay@gmail.com>
Tue, 3 Jul 2012 00:58:37 +0000 (10:58 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 3 Jul 2012 05:20:41 +0000 (15:20 +1000)
Thanks to Denis Bonnenfant <denis.bonnenfant@diderot.org> for patch.

source4/libcli/pysmb.c

index 14b05f7994820aeee1fa64b5509c5b4f40dc6e2e..1122305c283344106d1890c281aac159ec49e840 100644 (file)
@@ -262,6 +262,28 @@ static PyObject *py_smb_rmdir(pytalloc_Object *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
+/*
+ * Remove a directory and all its contents
+ */
+static PyObject *py_smb_deltree(pytalloc_Object *self, PyObject *args)
+{
+       int status;
+       const char *dirname;
+       struct smb_private_data *spdata;
+
+       if (!PyArg_ParseTuple(args, "s:deltree", &dirname)) {
+               return NULL;
+       }
+
+       spdata = self->ptr;
+       status = smbcli_deltree(spdata->tree, dirname);
+       if (status <= 0) {
+               return NULL;
+       }
+
+       Py_RETURN_NONE;
+}
+
 /*
  * Check existence of a path
  */
@@ -526,6 +548,9 @@ static PyMethodDef py_smb_methods[] = {
        { "rmdir", (PyCFunction)py_smb_rmdir, METH_VARARGS,
                "rmdir(path) -> None\n\n \
                Delete a directory." },
+       { "deltree", (PyCFunction)py_smb_deltree, METH_VARARGS,
+               "deltree(path) -> None\n\n \
+               Delete a directory and all its contents." },
        { "chkpath", (PyCFunction)py_smb_chkpath, METH_VARARGS,
                "chkpath(path) -> True or False\n\n \
                Return true if path exists, false otherwise." },