#include <pakfire/errno.h>
#include <pakfire/file.h>
#include <pakfire/filelist.h>
+#include <pakfire/i18n.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
#include <pakfire/pakfire.h>
#include <pakfire/private.h>
+#include <pakfire/progressbar.h>
#include <pakfire/repo.h>
#include <pakfire/types.h>
#include <pakfire/util.h>
}
PAKFIRE_EXPORT int pakfire_repo_scan(PakfireRepo repo, int flags) {
+ struct pakfire_progressbar* progressbar = NULL;
+
char* path = pakfire_repo_get_path(repo);
if (!path)
return EINVAL;
// Fetch how many files have been found
const size_t num_files = pakfire_filelist_size(filelist);
+ // Create progressbar
+ r = pakfire_progressbar_create(&progressbar, repo->pakfire, NULL);
+ if (r)
+ goto ERROR;
+
+ const char* name = pakfire_repo_get_name(repo);
+
+ // Add title to progressbar
+ r = pakfire_progressbar_add_string(progressbar, _("Scanning %s"), name);
+ if (r)
+ goto ERROR;
+
+ // Add the bar
+ r = pakfire_progressbar_add_bar(progressbar);
+ if (r)
+ goto ERROR;
+
+ // Add a counter
+ r = pakfire_progressbar_add_counter(progressbar);
+ if (r)
+ goto ERROR;
+
+ // Start progress bar
+ r = pakfire_progressbar_start(progressbar, num_files);
+
for (unsigned int i = 0; i < num_files; i++) {
PakfireFile file = pakfire_filelist_get(filelist, i);
+ // Increment progress bar
+ pakfire_progressbar_increment(progressbar);
+
// Skip anything that isn't a regular file
int type = pakfire_file_get_type(file);
if (type != S_IFREG) {
pakfire_file_unref(file);
}
+ // Finish the progress bar
+ r = pakfire_progressbar_finish(progressbar);
+ if (r)
+ goto ERROR;
+
+ // Success
+ r = 0;
+
ERROR:
+ if (progressbar)
+ pakfire_progressbar_unref(progressbar);
pakfire_filelist_unref(filelist);
return r;