return PyUnicode_FromString(path);
}
+static PyObject* Archive_get_filelist(ArchiveObject* self) {
+ int r;
+
+ // Fetch the filelist
+ struct pakfire_filelist* filelist = pakfire_archive_get_filelist(self->archive);
+ if (!filelist) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ const size_t size = pakfire_filelist_size(filelist);
+
+ // Create a new Python list
+ PyObject* list = PyList_New(0);
+ if (!list)
+ goto ERROR;
+
+ for (unsigned int i = 0; i < size; i++) {
+ struct pakfire_file* file = pakfire_filelist_get(filelist, i);
+ if (!file)
+ goto ERROR;
+
+ // Fetch the path
+ const char* path = pakfire_file_get_path(file);
+
+ // Convert path to string
+ PyObject* obj = PyUnicode_FromString(path);
+
+ // Append the new object to the list
+ r = PyList_Append(list, obj);
+ Py_DECREF(obj);
+
+ // If we could not append to the list, we will break
+ if (r) {
+ Py_DECREF(list);
+ list = NULL;
+ goto ERROR;
+ }
+
+ // Free file
+ pakfire_file_unref(file);
+ }
+
+ERROR:
+ if (filelist)
+ pakfire_filelist_unref(filelist);
+
+ return list;
+}
+
static struct PyMethodDef Archive_methods[] = {
{
"extract",
};
static struct PyGetSetDef Archive_getsetters[] = {
+ {
+ "filelist",
+ (getter)Archive_get_filelist,
+ NULL,
+ NULL,
+ NULL
+ },
{
"format",
(getter)Archive_get_format,