bool Config::saveJoystickConfig()
{
+ bool ret = true;
char filename[PATH_MAX];
snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);
if (!fp)
{
- debug(("WARNING: Couldn't save joystick config\n"));
+ debug(("WARNING: Couldn't save joystick config: %s\n", strerror(errno)));
return false;
}
-
- fwrite(&joystick, sizeof(Joystick), 1, fp);
-
+
+ if (fwrite(&joystick, sizeof(Joystick), 1, fp) != 1)
+ {
+ debug(("WARNING: Couldn't save joystick config: %s\n", strerror(errno)));
+ ret = false;
+ }
+
fclose(fp);
- return true;
+ return ret;
}
bool Config::loadKeyConfig()
bool Config::saveKeyConfig()
{
+ bool ret = true;
char filename[PATH_MAX];
snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);
if (!fp)
{
+ debug(("WARNING: Couldn't save keyboard config: %s\n", strerror(errno)));
return false;
}
-
- fwrite(&keyboard, sizeof(keyboard), 1, fp);
-
+
+ if (fwrite(&keyboard, sizeof(keyboard), 1, fp) != 1)
+ {
+ debug(("WARNING: Couldn't save keyboard config: %s\n", strerror(errno)));
+ ret = false;
+ }
+
fclose(fp);
- return true;
+ return ret;
}
void Config::restoreKeyDefaults()