From f2bfcfa5ba55e6dd0b38f032a1affbcf65835f8d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 13 Mar 2024 12:20:41 +0600 Subject: [PATCH] Changed new config file creation method --- source/libublsettingsui-gtk3.c | 10 +++++----- source/libublsettingsui-gtk3.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/libublsettingsui-gtk3.c b/source/libublsettingsui-gtk3.c index 5c4b088..4ee9e2d 100644 --- a/source/libublsettingsui-gtk3.c +++ b/source/libublsettingsui-gtk3.c @@ -285,11 +285,11 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){ if (!yon_char_is_empty(file)){ if (!strstr(file,".ini")) file = yon_char_append(file,".ini"); if (access(file,0)!=F_OK){ - FILE *source_file = fopen("/lib/ublinux/templates/ublinux-data.ini","r"); - FILE *dest_file = fopen(file,"w"); - int ch; - while ((ch = fgetc(source_file)) != EOF) { - fputc(ch, dest_file); + char *command_creation = ubconfig_file_create(file); + system(command_creation); + if (access(file,0)!=F_OK){ + yon_ubl_status_box_render(CUSTOM_CONFIG_CREATION_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + return NULL; } } } diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index bcb82b0..f41eb58 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -94,12 +94,15 @@ #define SAVE_MODE_RAM_HOME_LABEL _("Sandbox with profile saving") #define SAVE_MODE_HDD_LABEL _("HDD sandbox") #define SAVE_MODE_HDD_HOME_LABEL _("HDD sandbox with profile saving") + #define CUSTOM_CONFIG_CREATION_ERROR_LABEL _("New configuration file creation failed") #endif #define dull_parameter_get_command "ubconfig --source global get users PARAMETER" #define SAVE_MODE_GET_COMMAND "ubconfig --raw --source system get [config] SYSTEMBOOT_STATEMODE" +#define ubconfig_file_create(target) yon_char_unite("ubconfig --target \"",target,"\" create",NULL) + typedef enum SAVE_MODE_TYPE { SAVE_MODE_FULL, SAVE_MODE_MODULE,