Add check_mix_exists() function

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This commit is contained in:
Tudor Marcu
2017-11-03 11:50:08 -07:00
committed by Matthew Johnson
parent e18eb6917f
commit ebf0373f00
+34
View File
@@ -173,6 +173,40 @@ void print_time_stats(timelist *head)
}
}
/* If the MIX_BUNDLES_DIR has any content then we can run through
* adding the mix data to the OS */
bool check_mix_exists(void)
{
DIR *dir;
struct dirent *entry;
char *fullpath;
int i;
string_or_die(&fullpath, "%s%s", path_prefix, MIX_DIR);
dir = opendir(fullpath);
if (dir == NULL) {
free(fullpath);
return false;
}
for(i = 0; i < 3; i++) {
entry = readdir(dir);
if (!entry) {
break;
}
if (!strcmp(entry->d_name, ".") ||
!strcmp(entry->d_name, "..")) {
continue;
}
}
/* If more than /. & /.. exists, then at least one bundle exists */
if (i > 2) {
return true;
} else {
return false;
}
}
int get_value_from_path(char **contents, const char *path, bool is_abs_path)
{
char line[LINE_MAX];