public static PatchInfo ReadPatch(string path) { PatchInfo info = new PatchInfo { Path = System.IO.Path.GetDirectoryName(path) }; if (File.Exists(path)) { string[] lines = File.ReadAllLines(path); foreach (string line in lines) { string[] s = line.Split('='); if (s.Length == 2) { // Name if (s[0].ToLower() == "name") { info.Name = s[1]; } // Conflicts else if (s[0].ToLower() == "conflicts") { info.Conflicts.Add(s[1]); } // Requires else if (s[0].ToLower() == "requires") { info.Requires.Add(s[1]); } // Requires else if (s[0].ToLower() == "mods") { info.ReqiredMods.Add(s[1]); } } } } else { Utils.ShowError("Invalid Patch path\n\n" + path); return(null); } return(info); }
private void PopulatePatches() { patches.Clear(); checkedListBoxPatches.Items.Clear(); // Populate the patches list if (config.DRPGPath != string.Empty) { if (Directory.Exists(config.DRPGPath)) { List <string> folders = Directory.EnumerateDirectories(config.DRPGPath).ToList <string>(); foreach (string folder in folders) { List <string> files = Directory.EnumerateFiles(folder).ToList <string>(); bool isValid = false; foreach (string file in files) { if (file.Contains("DRPGINFO.txt")) { isValid = true; break; } } if (isValid) { PatchInfo info = PatchInfo.ReadPatch(folder + "\\DRPGINFO.txt"); patches.Add(info); } else { continue; } } } } // Populate the Patches checklist box foreach (PatchInfo patch in patches) { checkedListBoxPatches.Items.Add(patch); } }
public static PatchInfo ReadPatch(string path) { PatchInfo info = new PatchInfo(); info.path = System.IO.Path.GetDirectoryName(path); if (File.Exists(path)) { string[] lines = File.ReadAllLines(path); foreach (string line in lines) { string[] s = line.Split('='); if (s.Length != 2) continue; // Name if (s[0].ToLower() == "name") info.name = s[1]; // Conflicts if (s[0].ToLower() == "conflicts") info.conflicts.Add(s[1]); // Requires if (s[0].ToLower() == "requires") info.requires.Add(s[1]); } } else { Utils.ShowError("Invalid Patch path\n\n" + path); return null; } return info; }