2016-04-05 15:54:58 -07:00
|
|
|
|
using System;
|
2016-04-18 16:32:17 -07:00
|
|
|
|
using System.Collections.Generic;
|
2016-04-05 15:54:58 -07:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
|
|
|
|
using SabreTools.Helper;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DatSplit
|
|
|
|
|
|
{
|
|
|
|
|
|
class DatSplit
|
|
|
|
|
|
{
|
2016-04-06 00:47:28 -07:00
|
|
|
|
private static string _extA;
|
|
|
|
|
|
private static string _extB;
|
|
|
|
|
|
private static string _filename;
|
2016-04-05 15:54:58 -07:00
|
|
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2016-04-18 20:04:38 -07:00
|
|
|
|
Console.Clear();
|
2016-04-06 00:35:39 -07:00
|
|
|
|
|
2016-04-18 16:32:17 -07:00
|
|
|
|
// Credits take precidence over all
|
|
|
|
|
|
if ((new List<string>(args)).Contains("--credits"))
|
|
|
|
|
|
{
|
|
|
|
|
|
Build.Credits();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-05 15:54:58 -07:00
|
|
|
|
// If we don't have arguments, show help
|
|
|
|
|
|
if (args.Length == 0 && args.Length != 3)
|
|
|
|
|
|
{
|
2016-04-06 14:19:01 -07:00
|
|
|
|
Build.Help();
|
2016-04-05 15:54:58 -07:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
Logger logger = new Logger(false, "datsplit.log");
|
|
|
|
|
|
logger.Start();
|
|
|
|
|
|
|
2016-04-18 20:04:38 -07:00
|
|
|
|
// Output the title
|
|
|
|
|
|
Build.Start("DatSplit");
|
|
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
// Set needed variables
|
2016-04-06 00:47:28 -07:00
|
|
|
|
_filename = args[0];
|
2016-04-07 22:05:47 -07:00
|
|
|
|
_extA = (args[1].StartsWith(".") ? args[1] : "." + args[1]).ToUpperInvariant();
|
2016-04-07 17:16:13 -07:00
|
|
|
|
_extB = (args[2].StartsWith(".") ? args[2] : "." + args[2]).ToUpperInvariant();
|
2016-04-19 01:11:23 -07:00
|
|
|
|
List<RomData> romsA = new List<RomData>();
|
|
|
|
|
|
List<RomData> romsB = new List<RomData>();
|
2016-04-05 15:54:58 -07:00
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
// Load the current DAT to be processed
|
|
|
|
|
|
List<RomData> roms = RomManipulation.Parse(_filename, 0, 0, logger);
|
2016-04-05 15:54:58 -07:00
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
// Now separate the roms accordingly
|
|
|
|
|
|
foreach (RomData rom in roms)
|
2016-04-05 15:54:58 -07:00
|
|
|
|
{
|
2016-04-19 01:11:23 -07:00
|
|
|
|
if (rom.Name.ToUpperInvariant().EndsWith(_extA))
|
2016-04-05 15:54:58 -07:00
|
|
|
|
{
|
2016-04-19 01:11:23 -07:00
|
|
|
|
romsA.Add(rom);
|
2016-04-05 15:54:58 -07:00
|
|
|
|
}
|
2016-04-19 01:11:23 -07:00
|
|
|
|
else if (rom.Name.ToUpperInvariant().EndsWith(_extB))
|
2016-04-05 15:54:58 -07:00
|
|
|
|
{
|
2016-04-19 01:11:23 -07:00
|
|
|
|
romsB.Add(rom);
|
2016-04-05 15:54:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2016-04-19 01:11:23 -07:00
|
|
|
|
romsA.Add(rom);
|
|
|
|
|
|
romsB.Add(rom);
|
2016-04-05 15:54:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
// Then write out both files
|
|
|
|
|
|
Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extA, Path.GetFileNameWithoutExtension(_filename) + "." + _extA,
|
|
|
|
|
|
"", "", "", "", false, Path.GetExtension(_filename) == ".dat", "", romsA, logger);
|
|
|
|
|
|
Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extB, Path.GetFileNameWithoutExtension(_filename) + "." + _extB,
|
|
|
|
|
|
"", "", "", "", false, Path.GetExtension(_filename) == ".dat", "", romsB, logger);
|
2016-04-05 15:54:58 -07:00
|
|
|
|
|
2016-04-19 01:11:23 -07:00
|
|
|
|
logger.Close();
|
2016-04-05 15:54:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|