return r;
}
+int pakfire_db_filelist(struct pakfire_db* db, struct pakfire_filelist** filelist) {
+ struct pakfire_filelist* list = NULL;
+ sqlite3_stmt* stmt = NULL;
+ int r;
+
+ const char* sql =
+ "SELECT "
+ "path, "
+ "size, "
+ "mode, "
+ "user, "
+ "'group', "
+ "ctime, "
+ "mtime "
+ "FROM files "
+ "ORDER BY path"
+ ";";
+
+ // Prepare the statement
+ r = sqlite3_prepare_v2(db->handle, sql, strlen(sql), &stmt, NULL);
+ if (r) {
+ ERROR(db->pakfire, "Could not prepare SQL statement: %s %s\n",
+ sql, sqlite3_errmsg(db->handle));
+ goto ERROR;
+ }
+
+ // Create a new filelist
+ r = pakfire_filelist_create(&list, db->pakfire);
+ if (r)
+ goto ERROR;
+
+ // Iterate over all rows
+ for (;;) {
+ // Execute query
+ r = sqlite3_step(stmt);
+
+ switch (r) {
+ // Retry if the database was busy
+ case SQLITE_BUSY:
+ continue;
+
+ // Read a row
+ case SQLITE_ROW:
+ r = pakfire_db_load_file(db, list, stmt);
+ if (r)
+ goto ERROR;
+ break;
+
+ // All rows have been processed
+ case SQLITE_DONE:
+ r = 0;
+ goto END;
+
+ // Go to error in any other cases
+ default:
+ goto ERROR;
+ }
+ }
+
+END:
+ // Return the filelist
+ *filelist = pakfire_filelist_ref(list);
+
+ERROR:
+ if (r)
+ ERROR(db->pakfire, "Could not fetch filelist: %m\n");
+
+ if (stmt)
+ sqlite3_finalize(stmt);
+ if (list)
+ pakfire_filelist_unref(list);
+
+ return r;
+}
+
int pakfire_db_package_filelist(struct pakfire_db* db, struct pakfire_filelist** filelist,
struct pakfire_package* pkg) {
struct pakfire_filelist* fl = NULL;
struct pakfire_scriptlet* pakfire_db_get_scriptlet(
struct pakfire_db* db, struct pakfire_package* pkg, const char* type);
+int pakfire_db_filelist(struct pakfire_db* db, struct pakfire_filelist** filelist);
int pakfire_db_package_filelist(struct pakfire_db* db, struct pakfire_filelist** filelist,
struct pakfire_package* pkg);