int digests;
};
+static int pakfire_copy_data_from_file(struct pakfire* pakfire,
+ struct archive* archive, FILE* f) {
+ char buffer[BUFFER_SIZE];
+
+ ssize_t bytes_read = 0;
+ ssize_t bytes_written = 0;
+
+ // Read file from the very beginning - also allows calling this multiple times
+ rewind(f);
+
+ // Loop through the entire length of the file
+ while (!feof(f)) {
+ // Read a block from file
+ bytes_read = fread(buffer, 1, sizeof(buffer), f);
+
+ // Check if any error occured
+ if (ferror(f)) {
+ ERROR(pakfire, "Read error: %m\n");
+ return -errno;
+ }
+
+ // Write the block to the archive
+ bytes_written = archive_write_data(archive, buffer, bytes_read);
+ if (bytes_written < bytes_read) {
+ ERROR(pakfire, "Write error: %s\n", archive_error_string(archive));
+ return -errno;
+ }
+ }
+
+ return 0;
+}
+
static int __pakfire_compress_entry(struct pakfire* pakfire, struct pakfire_file* file,
struct pakfire_compress* data, struct archive_entry* entry) {
FILE* f = NULL;
}
// Copy the payload into the archive
- r = pakfire_archive_copy_data_from_file(pakfire, data->archive, f);
+ r = pakfire_copy_data_from_file(pakfire, data->archive, f);
if (r)
goto ERROR;
}
#include <pwd.h>
#include <stdio.h>
-#include <archive.h>
-
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
int pakfire_tty_is_noninteractive(void);
-// Archive Stuff
-
-int pakfire_archive_copy_data_from_file(struct pakfire* pakfire,
- struct archive* archive, FILE* f);
-
// JSON Stuff
struct json_object* pakfire_json_parse(struct pakfire_ctx* ctx,
#include <sys/types.h>
#include <unistd.h>
-#include <archive.h>
-#include <archive_entry.h>
#include <json.h>
#include <uuid/uuid.h>
return 0;
}
-// Archive Stuff
-
-int pakfire_archive_copy_data_from_file(struct pakfire* pakfire,
- struct archive* archive, FILE* f) {
- char buffer[BUFFER_SIZE];
-
- size_t bytes_read = 0;
- ssize_t bytes_written = 0;
-
- // Read file from the very beginning - also allows calling this multiple times
- rewind(f);
-
- // Loop through the entire length of the file
- while (!feof(f)) {
- // Read a block from file
- bytes_read = fread(buffer, 1, sizeof(buffer), f);
-
- // Check if any error occured
- if (ferror(f)) {
- ERROR(pakfire, "Read error: %m\n");
- return 1;
- }
-
- // Write the block to the archive
- bytes_written = archive_write_data(archive, buffer, bytes_read);
- if (bytes_written < 0) {
- ERROR(pakfire, "Write error: %s\n", archive_error_string(archive));
- return 1;
- }
- }
-
- return 0;
-}
-
// JSON Stuff
struct json_object* pakfire_json_parse(struct pakfire_ctx* ctx,