diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-11-28 22:41:37 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-11-28 22:41:37 (GMT) |
commit | 48395d4471d87c20bdbd06bbab1ae3af938ff823 (patch) | |
tree | 00aaaabb7370d6163ed9a2a4f77f9a177f8126f7 /plugins/pychrysalide/analysis/contents/file.c | |
parent | 472d566943f527e18eb95f31dbe70c50043396aa (diff) |
Improved the API for binary contents a little bit.
Diffstat (limited to 'plugins/pychrysalide/analysis/contents/file.c')
-rw-r--r-- | plugins/pychrysalide/analysis/contents/file.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/plugins/pychrysalide/analysis/contents/file.c b/plugins/pychrysalide/analysis/contents/file.c index f660656..dc7cdf9 100644 --- a/plugins/pychrysalide/analysis/contents/file.c +++ b/plugins/pychrysalide/analysis/contents/file.c @@ -39,6 +39,9 @@ /* Crée un nouvel objet Python de type 'BinContent'. */ static PyObject *py_file_content_new(PyTypeObject *, PyObject *, PyObject *); +/* Fournit le nom de fichier associé au contenu binaire. */ +static PyObject *py_file_content_get_filename(PyObject *, void *); + /****************************************************************************** @@ -62,6 +65,15 @@ static PyObject *py_file_content_new(PyTypeObject *type, PyObject *args, PyObjec int ret; /* Bilan de lecture des args. */ GBinContent *content; /* Version GLib du contenu */ +#define FILE_CONTENT_DOC \ + "FileContent handles binary content loaded from a file.\n" \ + "\n" \ + "Instances can be created using the following constructor:\n" \ + "\n" \ + " FileContent(filename)" \ + "\n" \ + "Where filename is a path to an existing file." + ret = PyArg_ParseTuple(args, "s", &filename); if (!ret) return NULL; @@ -79,6 +91,42 @@ static PyObject *py_file_content_new(PyTypeObject *type, PyObject *args, PyObjec /****************************************************************************** * * +* Paramètres : self = objet Python concerné par l'appel. * +* closure = non utilisé ici. * +* * +* Description : Fournit le nom de fichier associé au contenu binaire. * +* * +* Retour : Chemin d'accès au contenu binaire. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_file_content_get_filename(PyObject *self, void *closure) +{ + PyObject *result; /* Valeur à retourner */ + GFileContent *content; /* Contenu binaire à consulter */ + const char *filename; /* Chemin d'accès à transmettre*/ + +#define FILE_CONTENT_FILENAME_ATTRIB PYTHON_GET_DEF_FULL \ +( \ + filename, py_file_content, \ + "Provide the access path to the binary content." \ +) + + content = G_FILE_CONTENT(pygobject_get(self)); + + filename = g_file_content_get_filename(content); + + result = PyUnicode_FromString(filename); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit un accès à une définition de type à diffuser. * @@ -96,6 +144,7 @@ PyTypeObject *get_python_file_content_type(void) }; static PyGetSetDef py_file_content_getseters[] = { + FILE_CONTENT_FILENAME_ATTRIB, { NULL } }; @@ -108,7 +157,7 @@ PyTypeObject *get_python_file_content_type(void) .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_doc = "PyChrysalide binary file content", + .tp_doc = FILE_CONTENT_DOC, .tp_methods = py_file_content_methods, .tp_getset = py_file_content_getseters, |