Program.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. namespace OpenVIII.PAK_Extractor
  6. {
  7. internal class Program
  8. {
  9. #region Methods
  10. private static void Main(string[] args)
  11. {
  12. Memory.Init(null, null, null);
  13. string DestPath = Path.Combine(Memory.FF8DIRdata, "movies");
  14. //DestPath = Path.Combine(Path.GetTempPath(), "movies"); //comment out to default to ff8 folder.
  15. start:
  16. List<FileInfo> files = new List<FileInfo>(1);
  17. List<PAK> data = new List<PAK>(1);
  18. Console.WriteLine($"This tool is used to extract the movies from the FF8 CDs, to be more like the steam version.");
  19. Console.WriteLine($"Detecting Compact Disc drives...");
  20. foreach (DriveInfo drive in DriveInfo.GetDrives()
  21. .Where(d => d.DriveType == DriveType.CDRom && d.IsReady))
  22. {
  23. DirectoryInfo dir = drive.RootDirectory;
  24. Console.WriteLine($"Found disc: {dir}");
  25. Console.WriteLine($"Scanning for PAK files...");
  26. files.AddRange(dir.GetFiles("*", SearchOption.TopDirectoryOnly).Where(x =>
  27. x.FullName.EndsWith(".pak", StringComparison.OrdinalIgnoreCase)));
  28. }
  29. foreach (FileInfo f in files)
  30. {
  31. Console.WriteLine($"PAK file detected: {f}");
  32. PAK pak = new PAK(f);
  33. long SumHI = pak.Movies.Sum(g => g.BINK_HIGH.Size);
  34. long SumLO = pak.Movies.Sum(g => g.BINK_LOW.Size);
  35. long SumCA = pak.Movies.Sum(g => g.CAM.Size);
  36. Console.WriteLine($"PAK has {pak.Count} videos. Total of {SumHI / 1024} KB (HI Res BINK), {SumLO / 1024} KB (LOW Res BINK), {SumCA / 1024} KB (CAM)");
  37. data.Add(pak);
  38. }
  39. if (data.Count > 0)
  40. {
  41. Console.WriteLine($"Destination: {Path.GetFullPath(DestPath)}\nPress [Enter] to continue. If you'd like to override this path, type a new destination, and then press [ENTER].");
  42. string input = Console.ReadLine();
  43. if (!string.IsNullOrWhiteSpace(input.Trim()))
  44. {
  45. Console.WriteLine($"Changed destination to: {Path.GetFullPath(input)}");
  46. DestPath = input;
  47. }
  48. if (!Directory.Exists(DestPath))
  49. {
  50. Console.WriteLine($"Created directory.");
  51. Directory.CreateDirectory(DestPath);
  52. }
  53. foreach (PAK pak in data)
  54. {
  55. pak.Extract(DestPath);
  56. }
  57. }
  58. Console.WriteLine($"Insert disc and press [Enter].");
  59. Console.ReadLine();
  60. goto start;
  61. }
  62. #endregion Methods
  63. }
  64. }