Skip to content

Commit

Permalink
mmchelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
rounk-ctrl committed Sep 23, 2023
1 parent caa159b commit 5ada28c
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions Rectify11Installer/Core/Backend/MMCHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public static bool PatchAll()
List<string> r11Msc = new(Directory.GetFiles(Path.Combine(Variables.r11Files, "mmc"), "*.msc", SearchOption.TopDirectoryOnly));
CopyFiles(langMsc, usaMsc, r11Msc);

// exit if current language is en-us
if (CultureInfo.CurrentUICulture.Name == "en-US") return true;

List<string> r11LangMsc = new(Directory.GetFiles(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name), "*.msc", SearchOption.TopDirectoryOnly));
List<string> sysMsc = new(Directory.GetFiles(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp"), "*.msc", SearchOption.TopDirectoryOnly));
for (var i = 0; i < r11LangMsc.Count; i++)
Expand All @@ -37,7 +39,8 @@ public static bool PatchAll()
}
}
}
Directory.Delete(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp"), true);

Helper.SafeDirectoryDeletion(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp"), false);
var msc = Path.Combine(tempDir, "msc");
if (CultureInfo.CurrentUICulture.Name != "en-US")
{
Expand Down Expand Up @@ -76,32 +79,25 @@ private static void ReplaceString(string file, string r11file)
}
private static void CopyFiles(IReadOnlyList<string> langMsc, IList<string> usaMsc, IReadOnlyList<string> r11Msc)
{
if (Directory.Exists(Path.Combine(tempDir, "msc")))
{
Directory.Delete(Path.Combine(tempDir, "msc"));
}
string path = Path.Combine(tempDir, "msc");
Helper.SafeDirectoryDeletion(path, false);

Directory.CreateDirectory(Path.Combine(tempDir, "msc"));
if (CultureInfo.CurrentUICulture.Name != "en-US")
{
if (Directory.Exists(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name)))
{
Directory.Delete(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name));
}
Directory.CreateDirectory(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name));
path = Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name);
Helper.SafeDirectoryDeletion(path, false);
Directory.CreateDirectory(path);

if (Directory.Exists(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp")))
{
Directory.Delete(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp"));
}
Directory.CreateDirectory(Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp"));
path = Path.Combine(tempDir, "msc", CultureInfo.CurrentUICulture.Name, "temp");
Helper.SafeDirectoryDeletion(path, false);
Directory.CreateDirectory(path);
}
else
{
if (Directory.Exists(Path.Combine(tempDir, "msc", "en-US")))
{
Directory.Delete(Path.Combine(tempDir, "msc", "en-US"));
}
Directory.CreateDirectory(Path.Combine(tempDir, "msc", "en-US"));
path = Path.Combine(tempDir, "msc", "en-US");
Helper.SafeDirectoryDeletion(path, false);
Directory.CreateDirectory(path);
}
if (CultureInfo.CurrentUICulture.Name != "en-US")
{
Expand All @@ -122,7 +118,6 @@ private static void CopyFiles(IReadOnlyList<string> langMsc, IList<string> usaMs
for (var i = 0; i < langMsc.Count; i++)
{
if (Path.GetFileName(langMsc[i]) != Path.GetFileName(r11Msc[j])) continue;
Debug.WriteLine(langMsc[i]);
if (File.Exists(Path.Combine(backupDir, "msc", CultureInfo.CurrentUICulture.Name,
Path.GetFileName(r11Msc[j])))) continue;
if (Path.GetFileName(langMsc[i]) == "lusrmgr.msc"
Expand Down

0 comments on commit 5ada28c

Please sign in to comment.