int pakfire_filelist_scan(struct pakfire_filelist* list, const char* root,
const char** includes, const char** excludes) {
+ struct pakfire_file* file = NULL;
+ struct archive_entry* entry = NULL;
+ int r = 1;
+
DEBUG(list->pakfire, "Scanning %s...\n", root);
if (includes) {
if (!reader)
return 1;
- int r = 1;
+ // Allocate a new file entry
+ entry = archive_entry_new();
+ if (!entry)
+ goto ERROR;
char* paths[] = {
(char*)root, NULL,
DEBUG(list->pakfire, "Processing %s...\n", path);
- struct archive_entry* entry = archive_entry_new();
- if (!entry)
- goto ERROR;
+ // Reset the file entry
+ entry = archive_entry_clear(entry);
// Set path
archive_entry_set_pathname(entry, path);
// Set source path
archive_entry_copy_sourcepath(entry, node->fts_path);
+ // Read all file attributes from disk
r = archive_read_disk_entry_from_file(reader, entry, -1, node->fts_statp);
if (r) {
ERROR(list->pakfire, "Could not read from %s: %m\n", node->fts_path);
}
// Create file
- struct pakfire_file* file;
- r = pakfire_file_create(&file, list->pakfire);
+ r = pakfire_file_create_from_archive_entry(&file, list->pakfire, entry);
if (r)
goto ERROR;
- // Import attributes
- r = pakfire_file_copy_archive_entry(file, entry);
- if (r) {
- pakfire_file_unref(file);
- goto ERROR;
- }
-
// Append it to the list
r = pakfire_filelist_append(list, file);
if (r) {
r = 0;
ERROR:
+ if (entry)
+ archive_entry_free(entry);
archive_read_free(reader);
return r;