From e3828d4ccb131750e0064f17ba599db5bd662753 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 3 Jul 2012 10:58:37 +1000 Subject: s4-pysmb: Add deltree() method to remove directory and its contents Thanks to Denis Bonnenfant for patch. --- source4/libcli/pysmb.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source4/libcli/pysmb.c') diff --git a/source4/libcli/pysmb.c b/source4/libcli/pysmb.c index 14b05f7994..1122305c28 100644 --- a/source4/libcli/pysmb.c +++ b/source4/libcli/pysmb.c @@ -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." }, -- cgit