author | Alberto Bertogli
<albertito@gmail.com> 2004-09-14 05:24:58 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2007-07-15 13:23:10 UTC |
parent | 852f8982750fd884a809a6ebef4e35f641b0f19e |
bindings/python/libjio.c | +15 | -0 |
diff --git a/bindings/python/libjio.c b/bindings/python/libjio.c index c9492fb..6ee3d84 100644 --- a/bindings/python/libjio.c +++ b/bindings/python/libjio.c @@ -67,6 +67,20 @@ static void jf_dealloc(jfileobject *fp) PyObject_Del(fp); } +/* fileno */ +PyDoc_STRVAR(jf_fileno__doc, +"fileno()\n\ +\n\ +Return the file descriptor number for the file.\n"); + +static PyObject *jf_fileno(jfileobject *fp, PyObject *args) +{ + if (!PyArg_ParseTuple(args, ":fileno")) + return NULL; + + return PyInt_FromLong(fp->fs->fd); +} + /* read */ PyDoc_STRVAR(jf_read__doc, "read(size)\n\ @@ -304,6 +318,7 @@ static PyObject *jf_new_trans(jfileobject *fp, PyObject *args) /* method table */ static PyMethodDef jfile_methods[] = { + { "fileno", (PyCFunction)jf_fileno, METH_VARARGS, jf_fileno__doc }, { "read", (PyCFunction)jf_read, METH_VARARGS, jf_read__doc }, { "pread", (PyCFunction)jf_pread, METH_VARARGS, jf_pread__doc }, { "write", (PyCFunction)jf_write, METH_VARARGS, jf_write__doc },