From 0574eab8bc7d8e72db862ec36815835938a5fdf1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 24 Jun 2009 18:25:09 +0100 Subject: Generated code for 'mkdtemp' command. --- python/guestfs-py.c | 26 ++++++++++++++++++++++++++ python/guestfs.py | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+) (limited to 'python') diff --git a/python/guestfs-py.c b/python/guestfs-py.c index b1623fe5..263d3d9f 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -4606,6 +4606,31 @@ py_guestfs_scrub_freespace (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_mkdtemp (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + const char *template; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_mkdtemp", + &py_g, &template)) + return NULL; + g = get_handle (py_g); + + r = guestfs_mkdtemp (g, template); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -4777,6 +4802,7 @@ static PyMethodDef methods[] = { { (char *) "scrub_device", py_guestfs_scrub_device, METH_VARARGS, NULL }, { (char *) "scrub_file", py_guestfs_scrub_file, METH_VARARGS, NULL }, { (char *) "scrub_freespace", py_guestfs_scrub_freespace, METH_VARARGS, NULL }, + { (char *) "mkdtemp", py_guestfs_mkdtemp, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 0bc041e6..fec12a71 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -1704,3 +1704,22 @@ class GuestFS: """ return libguestfsmod.scrub_freespace (self._o, dir) + def mkdtemp (self, template): + u"""This command creates a temporary directory. The + "template" parameter should be a full pathname for the + temporary directory with the six characters being + "XXXXXX". + + For example: "/tmp/tmpXXXXXX" or "/Temp/tmpXXXXXX", the + second one being suitable for Windows. + + The name of the temporary directory that was created is + returned. + + The caller is responsible for deleting the temporary + directory and its contents after use. + + See also: mkdtemp(3) + """ + return libguestfsmod.mkdtemp (self._o, template) + -- cgit