Implement the store function, we'll need it for a UI

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
Ikey Doherty
2016-05-27 02:33:22 +01:00
parent f3601f9aa5
commit 37540822b0
2 changed files with 42 additions and 0 deletions
+35
View File
@@ -151,6 +151,41 @@ bool lsi_config_load(LsiConfig *config)
return true;
}
static inline const char *lsi_bool_to_string(bool b)
{
if (b) {
return "true";
}
return "false";
}
bool lsi_config_store(LsiConfig *config)
{
autofree(FILE) *fp = NULL;
autofree(char) *conf = NULL;
if (!config) {
return false;
}
conf = lsi_get_user_config_file();
if (!conf) {
return false;
}
fp = fopen(conf, "w");
if (!fp) {
return false;
}
if (fprintf(fp,
"[Steam]\nuse-native-runtime = %s\nforce-32bit = %s\n",
lsi_bool_to_string(config->use_native_runtime),
lsi_bool_to_string(config->force_32)) < 0) {
return false;
}
return true;
}
void lsi_config_load_defaults(LsiConfig *config)
{
assert(config != NULL);
+7
View File
@@ -44,6 +44,13 @@ bool lsi_config_load(LsiConfig *config);
*/
void lsi_config_load_defaults(LsiConfig *config);
/**
* Attempt to write the user config to disk.
* On failure, this function will return false, and errno will be set
* appropriately.
*/
bool lsi_config_store(LsiConfig *config);
/**
* Determine if the host system is 64-bit.
*