bool LauncherSettings::save() { FILE *fp = ini_open_for_write(const_cast<char*>(INI_MAIN), false, "DO NOT EDIT THIS FILE"); if (fp == NULL) return false; ini_write_type(fp, "[launcher]"); ini_write_data(fp, "exe_filepath", m_exe_filepath); ini_write_data(fp, "active_mod", m_active_mod); ini_write_data(fp, "showed_pilot_warning", m_showed_pilot_warning); ini_close(fp); return true; }
bool ModSettings::save_user() { char path_buffer[MAX_PATH]; char all_params[3000] = { 0 }; FILE *fp; // build command line (sans exe) if (*m_mod_params) { strcat(all_params, m_mod_params); strcat(all_params, " "); } if (*m_standard_params) { strcat(all_params, m_standard_params); strcat(all_params, " "); } if (*m_custom_params) { strcat(all_params, m_custom_params); strcat(all_params, " "); } trim(all_params); // write to config file check_cfg_file(path_buffer, true); fp = fopen(path_buffer, "wt"); if (fp) { fwrite(all_params, len * sizeof(char), 1, fp); fclose(fp); } // write standard params to ini file char ini_name[MAX_PATH]; sprintf(ini_name, "%s\\%s\\%s", LauncherSettings::get_exe_pathonly(), LauncherSettings::get_active_mod(), const_cast<char*>(INI_MOD_CUSTOM)); fp = ini_open_for_write(ini_name, false, "These are the user's custom settings; don't distribute them with the mod because he'll want to choose his own"); if (fp == NULL) return false; ini_write_type(fp, "[settings]"); ini_write_data(fp, "flags", m_standard_params); ini_close(fp); return true; }
void ini_write_data(FILE *fp, const char *type, bool data) { ini_write_data(fp, type, data ? "true" : "false"); }