return archive->path;
}
+const char* pakfire_archive_get_filename(struct pakfire_archive* self) {
+ struct pakfire_package* pkg = NULL;
+ const char* filename = NULL;
+
+ // Fetch the package
+ pkg = pakfire_archive_get_package(self);
+ if (!pkg)
+ goto ERROR;
+
+ // Fetch the filename from the package
+ filename = pakfire_package_get_filename(pkg);
+ if (!filename)
+ goto ERROR;
+
+ERROR:
+ if (pkg)
+ pakfire_package_unref(pkg);
+
+ return filename;
+}
+
unsigned int pakfire_archive_get_format(struct pakfire_archive* archive) {
return archive->format;
}
const char* path, const int flags, struct pakfire_progress* parent);
const char* pakfire_archive_get_path(struct pakfire_archive* archive);
+const char* pakfire_archive_get_filename(struct pakfire_archive* self);
unsigned int pakfire_archive_get_format(struct pakfire_archive* archive);
return PyUnicode_FromString(path);
}
+static PyObject* Archive_get_filename(ArchiveObject* self) {
+ const char* filename = pakfire_archive_get_filename(self->archive);
+ if (!filename)
+ Py_RETURN_NONE;
+
+ return PyUnicode_FromString(filename);
+}
+
static PyObject* Archive_get_filelist(ArchiveObject* self) {
struct pakfire_filelist* filelist = NULL;
int r;
NULL,
NULL
},
+ {
+ "filename",
+ (getter)Archive_get_filename,
+ NULL,
+ NULL,
+ NULL
+ },
{
"format",
(getter)Archive_get_format,
free(dump);
}
+ // Check filename
+ ASSERT_STRING_EQUALS(pakfire_archive_get_filename(archive), "dummy-1.0-1.test1.src.pfm");
+
// Check name
const char* name = pakfire_package_get_string(package, PAKFIRE_PKG_NAME);
ASSERT_STRING_EQUALS(name, "dummy");
self.assertIsInstance(archive, pakfire.Archive)
+ # Check for the correct filename
+ self.assertEqual(archive.filename, "dummy-1.0-1.test1.src.pfm")
+
if __name__ == "__main__":
tests.main()