You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.1 KiB
79 lines
3.1 KiB
#include "my_device.h"
|
|
|
|
vector vec_disk;
|
|
|
|
vector *get_device_vec()
|
|
{
|
|
return &vec_disk;
|
|
}
|
|
|
|
void device_disk_parsed() {
|
|
char *cmd = "findmnt -lo source,target,fstype,label -t ext4";
|
|
vector_init(&vec_disk);
|
|
int size = 0;
|
|
char **responce = yon_config_load(cmd, &size);
|
|
char *split_simvol = " ";
|
|
for (int index = 1; index < size; index++)
|
|
{
|
|
char *disk = yon_char_divide_search(responce[index], "\n", -1);
|
|
if (yon_char_find_count(disk, " ") != 0 && !strstr(disk, "zram") && !strstr(disk, "["))
|
|
{
|
|
int size_str = 0;
|
|
char** name_disk = yon_char_parse(disk, &size_str, " ");
|
|
int flag = 0;
|
|
device_config* obj_device_config = malloc(sizeof(device_config));
|
|
for (int index_1 = 0; index_1 < size_str; index_1++) {
|
|
if (strlen(name_disk[index_1])) {
|
|
if (flag == 0) {
|
|
obj_device_config->name_disk = yon_char_new(name_disk[index_1]);
|
|
}
|
|
else if (flag == 1) {
|
|
obj_device_config->mounted = yon_char_new(name_disk[index_1]);
|
|
}
|
|
else if (flag == 2) {
|
|
obj_device_config->file_system = yon_char_new(name_disk[index_1]);
|
|
}
|
|
else if (flag == 3) {
|
|
obj_device_config->type_dick = yon_char_new(name_disk[index_1]);
|
|
}
|
|
flag+=1;
|
|
}
|
|
}
|
|
obj_device_config->description_disk = yon_char_unite(obj_device_config->name_disk,split_simvol,
|
|
obj_device_config->file_system,
|
|
split_simvol,
|
|
obj_device_config->mounted,
|
|
split_simvol,
|
|
obj_device_config->type_dick, NULL);
|
|
vec_disk.pfVectorAdd(&vec_disk, obj_device_config);
|
|
philos_free_string_array(&name_disk, size_str);
|
|
}
|
|
free(disk);
|
|
}
|
|
philos_free_string_array(&responce, size);
|
|
}
|
|
|
|
void device_fill_disk(GtkWidget *combo_box_text, vector* vec_filt)
|
|
{
|
|
vector vec;
|
|
vector_init(&vec);
|
|
vec.pfVectorCopy(&vec, &vec_disk);
|
|
for (int i = 0; i < vec_filt->vectorList.total; i++) {
|
|
disk_status* _config_disk_remove = (disk_status*)vec_filt->pfVectorGet(vec_filt, i);
|
|
for (int index = 0; index < vec.vectorList.total; index++) {
|
|
device_config* _config_disk = (device_config*)vec.pfVectorGet(&vec, index);
|
|
if (strstr(_config_disk->name_disk, _config_disk_remove->device)) {
|
|
vec.pfVectorDelete(&vec, index);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (vec.vectorList.total > 0) {
|
|
for (int index = 0; index < vec.vectorList.total; index++)
|
|
{
|
|
device_config* _config_disk_remove = (device_config*)vec.pfVectorGet(&vec, index);
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box_text), yon_char_new(_config_disk_remove->description_disk));
|
|
}
|
|
}
|
|
}
|