Tool dedicated to isohacking for Xenosaga on Playstation 2
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.

93 lines
3.5 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. using System.Collections.Generic;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Text;
  5. namespace Hack.Xenosaga.Common
  6. {
  7. public class Functions
  8. {
  9. public static void usage()
  10. {
  11. Trace.WriteLine("");
  12. Trace.WriteLine("xenosaga <option> <file> [encode/regroup]");
  13. Trace.WriteLine(" option : -l = List files from index");
  14. Trace.WriteLine(" -u = Unpack files from index");
  15. Trace.WriteLine(" -p = Pack files from index");
  16. Trace.WriteLine(" -e = Extract text from file");
  17. Trace.WriteLine(" -i = Insert text from file");
  18. Trace.WriteLine(" file : File to process (-l, -p, -u=Index file (the first one of each decade : xenosaga.00, xenosaga.10, xenosaga.20...) ; -e, -i : filename)");
  19. Trace.WriteLine(" encode : (-e) Encoding of the output/input file (ANSI( default), ASCII, UTF8, UNICODE)");
  20. Trace.WriteLine(" regroup : (-p) true to pack all files in only one (ex: 11, 12, 13 in 11) ; false or empty (default) to keep the same system of increment files");
  21. }
  22. public static bool CheckArgs(string[] args, out Variables.stArgs listArgs)
  23. {
  24. listArgs = new Variables.stArgs();
  25. List<string> listActions = new List<string>() { "-l", "-p", "-u", "-e", "-i" };
  26. Trace.Write("Checking arguments : ");
  27. if (args.Length != 2 && args.Length != 3)
  28. {
  29. Trace.WriteLine("Incorrect number of parameter!");
  30. return false;
  31. }
  32. if (!listActions.Contains(args[0]))
  33. {
  34. Trace.WriteLine("Incorrect parameter - unknown <option>");
  35. return false;
  36. }
  37. if (!File.Exists(args[1]) && !Directory.Exists(args[1]))
  38. {
  39. Trace.WriteLine("Incorrect parameter - unknown <file>");
  40. return false;
  41. }
  42. if ((args.Length == 3 && args[0] == "-p") && (args[2] != "true" && args[2] != "false"))
  43. {
  44. Trace.WriteLine("Incorrect parameter - unknown <regroup>");
  45. return false;
  46. }
  47. if ((args.Length == 3 && (args[0] == "-e" || args[0] == "-i")) && (args[2] != "ANSI" && args[2] != "ASCII" && args[2] != "UTF8" && args[2] != "UNICODE"))
  48. {
  49. Trace.WriteLine("Incorrect parameter - unknown <encode>");
  50. return false;
  51. }
  52. listArgs.option = args[0];
  53. listArgs.filename = args[1];
  54. if (args.Length == 3 && listArgs.option == "-p")
  55. listArgs.regroup = args[2] == "true" ? true : false;
  56. listArgs.encode = args.Length == 2 ? Encoding.Default : null;
  57. if (args.Length == 3 && (listArgs.option == "-e" || listArgs.option == "-i"))
  58. {
  59. switch (args[2])
  60. {
  61. case "ASCII":
  62. listArgs.encode = Encoding.ASCII;
  63. break;
  64. case "UTF8":
  65. listArgs.encode = Encoding.UTF8;
  66. break;
  67. case "UNICODE":
  68. listArgs.encode = Encoding.Unicode;
  69. break;
  70. case "ANSI":
  71. default:
  72. listArgs.encode = Encoding.Default;
  73. break;
  74. }
  75. }
  76. Trace.WriteLine("OK");
  77. return true;
  78. }
  79. }
  80. }