private void cbxXML_SelectedIndexChanged(object sender, EventArgs e) { cbxChoices.DataSource = null; cbxChoices.DataBindings.Clear(); txtPatch.Text = ""; activesxmlname = "/configurations/" + cbxXML.SelectedItem.ToString() + ".txt"; parseXML xmlParser = new parseXML(); xmlParser.checkIfConfigExists(Properties.Settings.Default.riivopath + "//riivolution/" + cbxXML.SelectedItem.ToString() + ".xml", activesxmlname, lvwOptions, choicelist, patchlist); }
public void patchParse(string activexmlname, string inputxml, string riifolderpath, string sdcardpath, string region, ComboBox cbx) { // string apppath = Application.StartupPath; string dataprefix; string backuppath = apppath + "/backups/" + Path.GetFileNameWithoutExtension(cbx.Text); if (Directory.Exists(riifolderpath + "/DATA/")) { dataprefix = "/DATA/files/"; } else { dataprefix = "/files/"; } // RESTORE BACKUP FROM LAST TIME!!!! if (Directory.Exists(backuppath)) { CopyDir(backuppath, riifolderpath); Directory.Delete(backuppath, true); } parseXML xmlParser = new parseXML(); // DETERMINING THE ID FOR EACH PATH FROM THE XML (I could've done this earlier in the code but whatevs) string[] xmllines = File.ReadAllLines(apppath + activexmlname); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(inputxml); string root = "/"; if (!(xmlDoc.SelectSingleNode("//wiidisc").Attributes["root"] == null)) { root = xmlDoc.SelectSingleNode("//wiidisc").Attributes["root"].Value + "/"; } foreach (string line in xmllines) { string sectionname = line.Split('|')[1]; string optionname = line.Split('|')[2]; string choicename = line.Split('|')[3].Split(';')[0]; string patchid = ""; XmlNodeList sections = xmlDoc.SelectNodes("//wiidisc/options/section"); foreach (XmlNode section in sections) { XmlNodeList options = xmlDoc.SelectNodes(xmlParser.GetXPathToNode(section) + "/node()"); foreach (XmlNode option in options) { if (option.Attributes["name"].Value == optionname) { XmlNodeList choices = xmlDoc.SelectNodes(xmlParser.GetXPathToNode(option) + "/node()"); foreach (XmlNode choice in choices) { if (choice.Attributes["name"].Value == choicename) { patchid = xmlDoc.SelectSingleNode(xmlParser.GetXPathToNode(choice) + "/node()").Attributes["id"].Value; // PATCH PART // searching the correct information for the patches (eg what to copy and where to) XmlNodeList patches = xmlDoc.SelectNodes("//wiidisc/patch"); foreach (XmlNode patch in patches) { if (patch.Attributes["id"].Value == patchid) { XmlNodeList filesfolders = xmlDoc.SelectNodes(xmlParser.GetXPathToNode(patch) + "/node()"); foreach (XmlNode filefolder in filesfolders) { /* FOLDER PATCH STARTS HERE*/ if (filefolder.Name == "folder") { string disc = ""; string external = filefolder.Attributes["external"].Value.Replace("{$__region}", region); if (!(filefolder.Attributes["disc"] == null)) { disc = filefolder.Attributes["disc"].Value; bool create = false; if (!(filefolder.Attributes["create"] == null)) { if ((filefolder.Attributes["create"].Value == "true")) { create = true; } } string fullpatchpath = sdcardpath + root + "/" + external; if (create == false) { string[] filesinpatchfolder = Directory.GetFiles(fullpatchpath); foreach (string file in filesinpatchfolder) { string patchfilename = Path.GetFileName(file); if (File.Exists(riifolderpath + dataprefix + disc + "/" + patchfilename)) { Directory.CreateDirectory(backuppath + disc); File.Copy(riifolderpath + dataprefix + disc + "/" + patchfilename, backuppath + disc + "/" + patchfilename, true); } } } //MessageBox.Show(fullpatchpath + "\n" + riifolderpath + disc); CopyDir(fullpatchpath, riifolderpath + disc); } else { MessageBox.Show("Dolphiilution does not support folder patches without disc folder given yet! Will continue anyway. Can't garantuee if your ISO will work.", "Aww snap!"); } } /* FILE PATCH STARTS HERE*/ if (filefolder.Name == "file") { string disc = ""; disc = filefolder.Attributes["disc"].Value; string external = ""; external = filefolder.Attributes["external"].Value; bool create = false; if (!(filefolder.Attributes["create"] == null)) { if ((filefolder.Attributes["create"].Value == "true")) { create = true; } } if (create == false) { if (File.Exists(riifolderpath + dataprefix + disc)) { System.IO.Directory.CreateDirectory(Path.GetDirectoryName(backuppath + disc)); File.Copy(riifolderpath + dataprefix + disc, backuppath + disc, true); } } //MessageBox.Show(sdcardpath + root + "/" + external + "\n" + riifolderpath + dataprefix + disc); File.Copy(sdcardpath + root + "/" + external, riifolderpath + dataprefix + disc); } } } } } } } } } } }
private void cbxChoices_SelectedIndexChanged(object sender, EventArgs e) { parseXML patch = new parseXML(); patch.populatePatches(lvwOptions, cbxChoices, txtPatch, choicelist, patchlist, activesxmlname); }
private void lvwOptions_SelectedIndexChanged(object sender, EventArgs e) { parseXML bla = new parseXML(); bla.populateChoices(lvwOptions, cbxChoices, choicelist, activesxmlname); }