bool ConfigOptionsDialog::ParseConfigFile(const wxFileName & parseFileName, bool isPlugin) { // Check that the config definition file exists if(!parseFileName.FileExists()) { wxLogError("Unable to find config definition (%s) - file does not exist", parseFileName.GetFullPath().c_str()); return false; } // Parse the file ConfigParser parserLoader; if(!parserLoader.Parse(string(parseFileName.GetFullPath().c_str()))) { wxLogError("Error in parsing (%s)", parseFileName.GetFullPath().c_str()); return false; } // If this is a plugin, add to the plugin array if(isPlugin) { if(!ExtractConfigPlugins(parserLoader.GetRootToken())) { return false; } } else { // Create the main config options from the file if(!ExtractConfigHeaders(gridValues, parserLoader.GetRootToken())) { return false; } } // Log any unused tokens parserLoader.LogUnusedTokens(); return true; }
bool MainDialog::ReadDiskProfiles() { wxStandardPaths stdPaths; wxFileName dirProcess; // Get the main profile directory dirProcess.AssignDir(stdPaths.GetDataDir()); dirProcess.AppendDir("Profiles"); wxString profileDir = dirProcess.GetPath(); // Test if the directory exists if(!wxDir::Exists(profileDir)) { wxLogWarning("Unable to find profiles directory %s", profileDir.c_str()); return false; } // Get the profile filenames wxArrayString profileFileNameArray; if(wxDir::GetAllFiles(profileDir, &profileFileNameArray, wxString(wxT("*.xni")), wxDIR_FILES) == 0) { wxLogWarning("No profiles in directory %s", profileDir.c_str()); return false; } // Loop for all profiles diskProfiles.clear(); for(uint i=0; i<profileFileNameArray.GetCount(); i++) { // Load the profile data ConfigParser parserLoader; if(parserLoader.Parse(string(profileFileNameArray[i].c_str()))) { // Add to the profile array diskProfiles.push_back(*parserLoader.GetRootToken()); } } // Should also parse the user data directory //wxStandardPaths::GetUserDataDir // Check that some profiles were valid if(diskProfiles.size() <= 0) { wxLogWarning("No valid profiles loaded in directory %s", profileDir.c_str()); return false; } return true; }