};
static int pakfire_file_from_archive_entry(struct pakfire_file* file, struct archive_entry* entry) {
+ const char* path = NULL;
const char* attr = NULL;
const void* value = NULL;
size_t size = 0;
int r = 0;
// Set abspath
- r = pakfire_file_set_abspath(file, archive_entry_sourcepath(entry));
- if (r) {
- ERROR(file->pakfire, "Could not set abspath: %m\n");
- goto ERROR;
+ path = archive_entry_sourcepath(entry);
+ if (path) {
+ // Make path absolute
+ path = pakfire_path_abspath(path);
+ if (!path)
+ goto ERROR;
+
+ // Set
+ r = pakfire_file_set_abspath(file, path);
+ if (r) {
+ ERROR(file->pakfire, "Could not set abspath: %m\n");
+ goto ERROR;
+ }
}
// Set path
- const char* path = archive_entry_pathname(entry);
+ path = archive_entry_pathname(entry);
if (path) {
// Strip any leading dots from paths
if (pakfire_string_startswith(path, "./"))
return r;
}
-struct archive_entry* pakfire_file_archive_entry(struct pakfire_file* file) {
+struct archive_entry* pakfire_file_archive_entry(struct pakfire_file* file, int digest_types) {
struct archive_entry* entry = archive_entry_new();
if (!entry) {
ERROR(file->pakfire, "Could not allocate archive entry: %m\n");
return NULL;
}
- // Set path
- archive_entry_copy_pathname(entry, pakfire_file_get_path(file));
-
// Set source path
archive_entry_copy_sourcepath(entry, file->abspath);
+ // Set path
+ archive_entry_copy_pathname(entry, pakfire_file_get_path(file));
+
// Set links
if (*file->hardlink)
archive_entry_set_hardlink(entry, file->hardlink);
}
int pakfire_file_set_abspath(struct pakfire_file* file, const char* path) {
+ int r;
+
// Check if path is set and absolute
if (!path || *path != '/') {
errno = EINVAL;
return 1;
}
- return pakfire_string_set(file->abspath, path);
+ // Store the abspath
+ r = pakfire_string_set(file->abspath, path);
+ if (r)
+ goto ERROR;
+
+ // Store path if it isn't set, yet
+ if (!*file->path) {
+ r = pakfire_file_set_path(file, path);
+ if (r)
+ goto ERROR;
+ }
+
+ return r;
+
+ERROR:
+ ERROR(file->pakfire, "Could not set abspath '%s': %m\n", path);
+ return r;
}
PAKFIRE_EXPORT const char* pakfire_file_get_path(struct pakfire_file* file) {