33#include <archive_entry.h>
35#include "xbps_api_impl.h"
38xbps_archive_get_file(
struct archive *ar,
struct archive_entry *entry)
45 assert(entry != NULL);
47 buflen = (size_t)archive_entry_size(entry);
48 buf = malloc(buflen+1);
52 nbytes = archive_read_data(ar, buf, buflen);
53 if ((
size_t)nbytes != buflen) {
61xbps_dictionary_t HIDDEN
62xbps_archive_get_dictionary(
struct archive *ar,
struct archive_entry *entry)
64 xbps_dictionary_t d = NULL;
67 if ((buf = xbps_archive_get_file(ar, entry)) == NULL)
71 d = xbps_dictionary_internalize(buf);
78 const char *fname,
const mode_t mode,
const char *uname,
const char *gname)
80 struct archive_entry *entry;
88 entry = archive_entry_new();
90 return archive_errno(ar);
92 archive_entry_set_filetype(entry, AE_IFREG);
93 archive_entry_set_perm(entry, mode);
94 archive_entry_set_uname(entry, uname);
95 archive_entry_set_gname(entry, gname);
96 archive_entry_set_pathname(entry, fname);
97 archive_entry_set_size(entry, buflen);
99 if (archive_write_header(ar, entry) != ARCHIVE_OK) {
100 archive_entry_free(entry);
101 return archive_errno(ar);
103 if (archive_write_data(ar, buf, buflen) != ARCHIVE_OK) {
104 archive_entry_free(entry);
105 return archive_errno(ar);
107 if (archive_write_finish_entry(ar) != ARCHIVE_OK) {
108 archive_entry_free(entry);
109 return archive_errno(ar);
111 archive_entry_free(entry);
int xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen, const char *fname, const mode_t mode, const char *uname, const char *gname)