summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorJoe Guo <joeg@catalyst.net.nz>2018-06-13 10:39:57 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-06-28 09:25:08 +0200
commit4320dcc4bc32ef26c2bd512b94e3bc9aedb9d192 (patch)
tree9a32d618f373e3fc6a2ac01f22fd92d93024668e /source4/libcli
parent211275fae6895cdedbbe25ca3e41d0a856c1a370 (diff)
downloadsamba-4320dcc4bc32ef26c2bd512b94e3bc9aedb9d192.tar.gz
pysmb: add py_smb_unlink and test
Add unlink api to delete a file with a smb connection. Test added. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/pysmb.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source4/libcli/pysmb.c b/source4/libcli/pysmb.c
index 5bb3807ab76..a53e30bcf91 100644
--- a/source4/libcli/pysmb.c
+++ b/source4/libcli/pysmb.c
@@ -258,6 +258,27 @@ static PyObject *py_smb_rmdir(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+
+/*
+ * Remove a file
+ */
+static PyObject *py_smb_unlink(PyObject *self, PyObject *args)
+{
+ NTSTATUS status;
+ const char *filename;
+ struct smb_private_data *spdata;
+
+ if (!PyArg_ParseTuple(args, "s:unlink", &filename)) {
+ return NULL;
+ }
+
+ spdata = pytalloc_get_ptr(self);
+ status = smbcli_unlink(spdata->tree, filename);
+ PyErr_NTSTATUS_IS_ERR_RAISE(status);
+
+ Py_RETURN_NONE;
+}
+
/*
* Remove a directory and all its contents
*/
@@ -551,6 +572,9 @@ FILE_ATTRIBUTE_ARCHIVE\n\n \
{ "rmdir", py_smb_rmdir, METH_VARARGS,
"rmdir(path) -> None\n\n \
Delete a directory." },
+ { "unlink", py_smb_unlink, METH_VARARGS,
+ "unlink(path) -> None\n\n \
+ Delete a file." },
{ "deltree", py_smb_deltree, METH_VARARGS,
"deltree(path) -> None\n\n \
Delete a directory and all its contents." },