}
// Generate a file object
- r = pakfire_file_create_from_archive_entry(&file, archive->root, entry);
+ r = pakfire_file_create_from_archive_entry(&file, archive->ctx, archive->root, entry);
if (r < 0)
goto ERROR;
int r;
// Generate a file object
- r = pakfire_file_create_from_archive_entry(&file, archive->root, entry);
+ r = pakfire_file_create_from_archive_entry(&file, archive->ctx, archive->root, entry);
if (r < 0)
goto ERROR;
}
// Create a new file object
- r = pakfire_file_create(&file, db->root, path);
+ r = pakfire_file_create(&file, db->ctx, db->root, path);
if (r < 0)
goto ERROR;
return r;
}
-int pakfire_file_create(pakfire_file** file, pakfire_root* root, const char* path) {
+int pakfire_file_create(pakfire_file** file,
+ pakfire_ctx* ctx, pakfire_root* root, const char* path) {
pakfire_file* f = NULL;
int r = 0;
return -errno;
// Store a reference to the context
- f->ctx = pakfire_root_get_ctx(root);
+ f->ctx = pakfire_ctx_ref(ctx);
// Store reference to the root
f->root = pakfire_root_ref(root);
return r;
}
-int pakfire_file_create_from_archive_entry(pakfire_file** file, pakfire_root* root,
- struct archive_entry* entry) {
+int pakfire_file_create_from_archive_entry(pakfire_file** file,
+ pakfire_ctx* ctx, pakfire_root* root, struct archive_entry* entry) {
pakfire_file* f = NULL;
int r;
- r = pakfire_file_create(&f, root, NULL);
+ r = pakfire_file_create(&f, ctx, root, NULL);
if (r < 0)
goto ERROR;
typedef struct pakfire_file pakfire_file;
+#include <pakfire/ctx.h>
#include <pakfire/hashes.h>
#include <pakfire/root.h>
PAKFIRE_FILE_CONFIG = (1 << 0),
};
-int pakfire_file_create(pakfire_file** file, pakfire_root* root, const char* path);
+int pakfire_file_create(pakfire_file** file,
+ pakfire_ctx* ctx, pakfire_root* root, const char* path);
pakfire_file* pakfire_file_ref(pakfire_file* file);
pakfire_file* pakfire_file_unref(pakfire_file* file);
int pakfire_file_write_fcaps(pakfire_file* file, struct vfs_cap_data* cap_data);
int pakfire_file_create_from_archive_entry(pakfire_file** file,
- pakfire_root* root, struct archive_entry* entry);
+ pakfire_ctx* ctx, pakfire_root* root, struct archive_entry* entry);
struct archive_entry* pakfire_file_archive_entry(pakfire_file* file, const enum pakfire_hash_type hashes);
enum pakfire_file_dump_flags {
}
// Create file
- r = pakfire_file_create_from_archive_entry(&file, list->root, entry);
+ r = pakfire_file_create_from_archive_entry(&file, list->ctx, list->root, entry);
if (r)
goto ERROR;
int r;
// Fetch a file object
- r = pakfire_file_create_from_archive_entry(&file, linter->root, e);
+ r = pakfire_file_create_from_archive_entry(&file, linter->ctx, linter->root, e);
if (r < 0)
goto ERROR;
}
typedef struct pakfire_package_filelist_search {
+ pakfire_ctx* ctx;
pakfire_root* root;
pakfire_filelist* filelist;
int r;
}
// Create a new file entry
- r = pakfire_file_create(&file, search->root, path);
+ r = pakfire_file_create(&file, search->ctx, search->root, path);
if (r < 0)
goto ERROR;
static int pakfire_package_fetch_filelist(pakfire_package* pkg, pakfire_filelist* filelist) {
pakfire_package_filelist_search search = {
+ .ctx = pkg->ctx,
.root = pkg->root,
.filelist = filelist,
.r = 0,
}
// Create a new file object from the archive entry
- r = pakfire_file_create_from_archive_entry(&file, packager->root, entry);
+ r = pakfire_file_create_from_archive_entry(&file, packager->ctx, packager->root, entry);
if (r < 0) {
ERROR(packager->ctx, "Could not create file object: %s\n", strerror(-r));
goto ERROR;
return 0;
// Create a new file object
- r = pakfire_file_create(&file, self->root, filename);
+ r = pakfire_file_create(&file, self->ctx, self->root, filename);
if (r < 0)
goto ERROR;
pakfire_file* file = NULL;
// Create a new file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->root, NULL));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->ctx, t->root, NULL));
// Set path & check
ASSERT_SUCCESS(pakfire_file_set_path(file, "/abc"));
pakfire_file* file = NULL;
// Create a new file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->root, NULL));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->ctx, t->root, NULL));
// Set path
ASSERT(pakfire_file_set_path(file, NULL) == -EINVAL);
ASSERT_SUCCESS(pakfire_filelist_create(&list, t->root));
// Create some files
- ASSERT_SUCCESS(pakfire_file_create(&file1, t->root, "/1"));
- ASSERT_SUCCESS(pakfire_file_create(&file2, t->root, "/2"));
- ASSERT_SUCCESS(pakfire_file_create(&file3, t->root, "/3"));
+ ASSERT_SUCCESS(pakfire_file_create(&file1, t->ctx, t->root, "/1"));
+ ASSERT_SUCCESS(pakfire_file_create(&file2, t->ctx, t->root, "/2"));
+ ASSERT_SUCCESS(pakfire_file_create(&file3, t->ctx, t->root, "/3"));
// Add the files to the list
ASSERT_SUCCESS(pakfire_filelist_add(list, file1));
ASSERT_SUCCESS(pakfire_filelist_create(&filelist, t->root));
// Create a file
- ASSERT_SUCCESS(pakfire_file_create(&file, t->root, "/bin/bash"));
+ ASSERT_SUCCESS(pakfire_file_create(&file, t->ctx, t->root, "/bin/bash"));
// Append the file to the filelist
ASSERT_SUCCESS(pakfire_filelist_add(filelist, file));