Navigation Menu

Skip to content

Commit

Permalink
Replacing Directory.GetFiles with recursive search function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MainMemory committed Mar 17, 2016
1 parent 8019678 commit 55b4182
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SADXModManager/MainForm.cs
Expand Up @@ -104,7 +104,7 @@ private void LoadModList()
mods = new Dictionary<string, ModInfo>();
codes = new List<Code>(mainCodes.Codes);
string modDir = Path.Combine(Environment.CurrentDirectory, "mods");
foreach (string filename in Directory.GetFiles(modDir, "mod.ini", SearchOption.AllDirectories))
foreach (string filename in GetModFiles(new DirectoryInfo(modDir)))
mods.Add(Path.GetDirectoryName(filename).Substring(modDir.Length + 1), IniFile.Deserialize<ModInfo>(filename));
modListView.BeginUpdate();
foreach (string mod in new List<string>(loaderini.Mods))
Expand Down Expand Up @@ -138,6 +138,18 @@ private void LoadModList()
codesCheckedListBox.EndUpdate();
}

private IEnumerable<string> GetModFiles(DirectoryInfo directoryInfo)
{
List<string> files = new List<string>();
foreach (DirectoryInfo item in directoryInfo.GetDirectories())
if (!item.Name.Equals("system", StringComparison.OrdinalIgnoreCase))
files.AddRange(GetModFiles(item));
string modini = Path.Combine(directoryInfo.FullName, "mod.ini");
if (File.Exists(modini))
files.Add(modini);
return files;
}

private void modListView_SelectedIndexChanged(object sender, EventArgs e)
{
int count = modListView.SelectedIndices.Count;
Expand Down

0 comments on commit 55b4182

Please sign in to comment.