From ed40ff253a88ab399c28cf22005193e7389d5e23 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 15 Oct 2009 11:34:26 +0300 Subject: Add tell() method to rpm.fd class --- python/rpmfd-py.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'python/rpmfd-py.c') diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c index 8458410d0..077cf9e1f 100644 --- a/python/rpmfd-py.c +++ b/python/rpmfd-py.c @@ -182,6 +182,16 @@ static PyObject *rpmfd_seek(rpmfdObject *s, PyObject *args, PyObject *kwds) Py_RETURN_NONE; } +static PyObject *rpmfd_tell(rpmfdObject *s) +{ + off_t offset; + Py_BEGIN_ALLOW_THREADS + offset = Ftell(s->fd); + Py_END_ALLOW_THREADS + return Py_BuildValue("L", offset); + +} + static PyObject *rpmfd_read(rpmfdObject *s, PyObject *args, PyObject *kwds) { char *kwlist[] = { "size", NULL }; @@ -257,6 +267,8 @@ static struct PyMethodDef rpmfd_methods[] = { NULL }, { "seek", (PyCFunction) rpmfd_seek, METH_VARARGS|METH_KEYWORDS, NULL }, + { "tell", (PyCFunction) rpmfd_tell, METH_NOARGS, + NULL }, { "write", (PyCFunction) rpmfd_write, METH_VARARGS|METH_KEYWORDS, NULL }, { NULL, NULL } -- cgit v1.2.3