Rewrite command_event_save_config

This commit is contained in:
twinaphex 2017-11-23 18:07:28 +01:00
parent 3bda00edaf
commit 096686140d
2 changed files with 22 additions and 18 deletions

View File

@ -1374,29 +1374,32 @@ error:
return false;
}
static bool command_event_save_config(const char *config_path,
static bool command_event_save_config(
const char *config_path,
char *s, size_t len)
{
if (string_is_empty(config_path) || !config_save_file(config_path))
bool path_exists = !string_is_empty(config_path);
const char *str = path_exists ? config_path :
path_get(RARCH_PATH_CONFIG);
if (path_exists && config_save_file(config_path))
{
const char *str = path_get(RARCH_PATH_CONFIG);
if (!string_is_empty(str))
{
snprintf(s, len, "%s \"%s\".",
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
str);
RARCH_ERR("%s\n", s);
}
return false;
snprintf(s, len, "[Config]: %s \"%s\".",
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
config_path);
RARCH_LOG("%s\n", s);
return true;
}
snprintf(s, len, "[Config]: %s \"%s\".",
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
config_path);
RARCH_LOG("%s\n", s);
return true;
if (!string_is_empty(str))
{
snprintf(s, len, "%s \"%s\".",
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
str);
RARCH_ERR("%s\n", s);
}
return false;
}
/**

View File

@ -20,6 +20,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <ctype.h>
#include <compat/strl.h>