summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/contents/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/contents/file.c')
-rw-r--r--plugins/pychrysalide/analysis/contents/file.c51
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,