bool Config::LoadINI(INIReader* config, const char* location, const std::string& default_contents, bool retry) { if (config->ParseError() < 0) { if (retry) { LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); FileUtil::CreateFullPath(location); FileUtil::WriteStringToFile(true, default_contents, location); *config = INIReader(location); // Reopen file return LoadINI(config, location, default_contents, false); } LOG_ERROR(Config, "Failed."); return false; } LOG_INFO(Config, "Successfully loaded %s", location); return true; }
bool Config::LoadINI(const std::string& default_contents, bool retry) { const char* location = this->sdl2_config_loc.c_str(); if (sdl2_config->ParseError() < 0) { if (retry) { LOG_WARNING(Config, "Failed to load %s. Creating file from defaults...", location); FileUtil::CreateFullPath(location); FileUtil::WriteStringToFile(true, default_contents, location); sdl2_config = std::make_unique<INIReader>(location); // Reopen file return LoadINI(default_contents, false); } LOG_ERROR(Config, "Failed."); return false; } LOG_INFO(Config, "Successfully loaded %s", location); return true; }
BOOL XMain::LoadRes( void ) { LoadINI(); // XE::LANG.LoadINI( XE::MakePath( _T(""), _T("lang.txt") ) ); /* TCHAR szRes[ 256 ]; TEXT_TBL = new XTextTable; LPCTSTR szFile = XE::Format( _T("text_%s.txt"), XE::LANG.GetszFolder() ); _tcscpy_s( szRes, XE::MakePath( DIR_PROP, szFile ) ); if( TEXT_TBL->Load( szRes ) == FALSE ) { XALERT("%s load failed", szRes ); return FALSE; } // CONSTANT = new XConstant; CONSTANT->Load( _T("defineGame.h") ); // 상수값들 읽어서 메모리에 적재 */ return TRUE; }
void Config::Reload() { LoadINI(glfw_config, glfw_config_loc.c_str(), DefaultINI::glfw_config_file); ReadValues(); }
void Config::Reload() { LoadINI(DefaultINI::sdl2_config_file); ReadValues(); }