Add function that reads local installed bundles

This function reads installed bundles from local standard
directory and store them in a list pointer passed as argument, this
function is the base for functionality as listing installed bundles to
user.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This commit is contained in:
Mario Alfredo Carrillo Arevalo
2017-01-18 09:52:49 -08:00
committed by tmarcu
parent af8fa61a6b
commit c244d36be3
2 changed files with 31 additions and 0 deletions
+1
View File
@@ -310,6 +310,7 @@ extern int remove_bundle(const char *bundle_name);
extern int list_installable_bundles();
extern int install_bundles_frontend(char **bundles);
extern int add_subscriptions(struct list *bundles, struct list **subs, int current_version, struct manifest *mom, int recursion);
void read_local_bundles(struct list **list_bundles);
/* telemetry.c */
typedef enum telem_prio_t {
+30
View File
@@ -589,3 +589,33 @@ clean_and_exit:
return ret;
}
/*
* This function will read /usr/share/clear/bundles/
* in order to get the bundle names, these will be
* saved in a list.
*/
void read_local_bundles(struct list **list_bundles)
{
char *path = NULL;
DIR *dir;
struct dirent *ent;
string_or_die(&path, "%s/%s", path_prefix, BUNDLES_DIR);
dir = opendir(path);
if (dir) {
while ((ent = readdir(dir))) {
if ((strcmp(ent->d_name, ".") == 0) ||
(strcmp(ent->d_name, "..") == 0)) {
continue;
}
*list_bundles = list_append_data(*list_bundles, ent->d_name);
}
closedir(dir);
}
free(path);
}