A fork of Eusth's IPA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. namespace IPA
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. if(args.Length < 1 || !args[0].EndsWith(".exe"))
  13. {
  14. Fail("Drag an (executable) file on the exe!");
  15. }
  16. string launcherSrc = Path.Combine("IPA", "Launcher.exe");
  17. string managedFolder = Path.Combine("IPA", "Managed");
  18. // Sanitizing
  19. if (!File.Exists(launcherSrc)) Fail("Couldn't find launcher! Make sure you extracted all contents of the release archive.");
  20. if (!File.Exists(launcherSrc)) Fail("Couldn't find DLLs! Make sure you extracted all contents of the release archive.");
  21. // Copying
  22. try
  23. {
  24. string projectName = Path.GetFileNameWithoutExtension(args[0]);
  25. string launcherPath = Path.Combine(Environment.CurrentDirectory, projectName + "_Patched.exe");
  26. string dataPath = Path.Combine(Path.Combine(Environment.CurrentDirectory, projectName + "_Data"), "Managed");
  27. File.Copy(launcherSrc, launcherPath, true);
  28. CopyAll(new DirectoryInfo(managedFolder), new DirectoryInfo(dataPath));
  29. Console.WriteLine("Successfully copied files!");
  30. } catch(Exception e)
  31. {
  32. Fail("Oops! This should not have happened.\n\n" + e);
  33. }
  34. }
  35. public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
  36. {
  37. Directory.CreateDirectory(target.FullName);
  38. // Copy each file into the new directory.
  39. foreach (FileInfo fi in source.GetFiles())
  40. {
  41. Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
  42. fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
  43. }
  44. // Copy each subdirectory using recursion.
  45. foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
  46. {
  47. DirectoryInfo nextTargetSubDir =
  48. target.CreateSubdirectory(diSourceSubDir.Name);
  49. CopyAll(diSourceSubDir, nextTargetSubDir);
  50. }
  51. }
  52. static void Fail(string message)
  53. {
  54. Console.BackgroundColor = ConsoleColor.Red;
  55. Console.ForegroundColor = ConsoleColor.White;
  56. Console.Write("{0,80}", "");
  57. Console.Write("{0,-80}", " "+message);
  58. Console.Write("{0,80}", "");
  59. Console.ReadLine();
  60. Environment.Exit(1);
  61. }
  62. }
  63. }