// Copy the data if there is any
if (archive_entry_size(entry)) {
// Open the file
- f = pakfire_file_fopen(file);
+ f = pakfire_file_fopen(file, "r");
if (!f) {
r = -errno;
goto ERROR;
return fd;
}
-FILE* pakfire_file_fopen(struct pakfire_file* file) {
+FILE* pakfire_file_fopen(struct pakfire_file* file, const char* mode) {
+ const char* path = NULL;
FILE* f = NULL;
- int fd = -EBADF;
- // Open the file descriptor
- fd = pakfire_file_open(file, O_RDONLY);
- if (fd < 0)
+ // Fetch the absolute path of the file
+ path = pakfire_file_get_abspath(file);
+ if (!path)
return NULL;
// Return a file handle
- f = fdopen(fd, "r");
+ f = fopen(path, mode);
if (!f) {
ERROR(file->ctx, "Could not open file handle for %s: %m\n",
pakfire_file_get_path(file));
return 0;
// Open the file
- f = pakfire_file_fopen(file);
+ f = pakfire_file_fopen(file, "r");
if (!f) {
r = 1;
goto ERROR;
pakfire_digests_reset(digests, types);
// Open the file
- f = pakfire_file_fopen(file);
+ f = pakfire_file_fopen(file, "r");
if (!f) {
r = -errno;
goto ERROR;
return r;
// Open the file
- f = pakfire_file_fopen(file);
+ f = pakfire_file_fopen(file, "r");
if (!f) {
ERROR(file->ctx, "Could not open %s: %m\n", pakfire_file_get_path(file));
return 1;
const char* pakfire_file_get_abspath(struct pakfire_file* file);
int pakfire_file_open(struct pakfire_file* file, int flags);
-FILE* pakfire_file_fopen(struct pakfire_file* file);
+FILE* pakfire_file_fopen(struct pakfire_file* file, const char* mode);
int pakfire_file_payload_matches(struct pakfire_file* file,
const void* needle, const size_t length);