return NULL;
}
-struct pakfire_archive* pakfire_package_get_archive(struct pakfire_package* pkg) {
- struct pakfire_archive* archive = NULL;
+int pakfire_package_get_archive(struct pakfire_package* pkg, struct pakfire_archive** archive) {
const char* path = NULL;
int r;
// Fetch the path
path = pakfire_package_get_path(pkg);
if (!path)
- return NULL;
+ return -errno;
// Open archive
- r = pakfire_archive_open(&archive, pkg->pakfire, path);
- if (r) {
- ERROR(pkg->ctx, "Could not open archive for %s (at %s): %m\n",
- pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA), path);
- return NULL;
+ r = pakfire_archive_open(archive, pkg->pakfire, path);
+ if (r < 0) {
+ ERROR(pkg->ctx, "Could not open archive for %s (at %s): %s\n",
+ pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA), path, strerror(-r));
+ return r;
}
- return archive;
+ return 0;
}
struct pakfire_package_filelist_search {
char* pakfire_package_dump(struct pakfire_package* pkg, int flags);
-struct pakfire_archive* pakfire_package_get_archive(struct pakfire_package* pkg);
+int pakfire_package_get_archive(struct pakfire_package* pkg, struct pakfire_archive** archive);
struct pakfire_filelist* pakfire_package_get_filelist(struct pakfire_package* pkg);
int pakfire_package_set_filelist(struct pakfire_package* pkg, struct pakfire_filelist* filelist);
return -EINVAL;
// Fetch the archive
- archive = pakfire_package_get_archive(pkg);
- if (!archive)
- return -errno;
+ r = pakfire_package_get_archive(pkg, &archive);
+ if (r < 0)
+ return r;
// Call the callback
r = state->callback(ctx, pkg, archive, state->data);
}
static int pakfire_transaction_open_archives(struct pakfire_transaction* transaction) {
+ int r;
+
for (unsigned int i = 0; i < transaction->num; i++) {
struct pakfire_package* pkg = transaction->packages[i];
continue;
}
- transaction->archives[i] = pakfire_package_get_archive(pkg);
- if (!transaction->archives[i])
- return 1;
+ // Open the archive
+ r = pakfire_package_get_archive(pkg, &transaction->archives[i]);
+ if (r < 0)
+ return r;
}
return 0;