diff --git a/RombaSharp/Partials/RombaSharp_Inits.cs b/RombaSharp/Partials/RombaSharp_Inits.cs index babcee68..2cc8f5a4 100644 --- a/RombaSharp/Partials/RombaSharp_Inits.cs +++ b/RombaSharp/Partials/RombaSharp_Inits.cs @@ -62,7 +62,7 @@ namespace SabreTools FileName = Path.GetFileName(inputs[0]) + " Dir2Dat", Name = Path.GetFileName(inputs[0]) + " Dir2Dat", Description = Path.GetFileName(inputs[0]) + " Dir2Dat", - OutputFormat = OutputFormat.Xml, + OutputFormat = OutputFormat.Logiqx, Files = new SortedDictionary>(), }; diff --git a/SabreTools.Helper/Data/Flags.cs b/SabreTools.Helper/Data/Flags.cs index 168b4c3d..001db59c 100644 --- a/SabreTools.Helper/Data/Flags.cs +++ b/SabreTools.Helper/Data/Flags.cs @@ -20,7 +20,7 @@ namespace SabreTools.Helper [Flags] public enum OutputFormat { - Xml = 0x001, + Logiqx = 0x001, ClrMamePro = 0x002, RomCenter = 0x004, DOSCenter = 0x008, diff --git a/SabreTools.Helper/Objects/Dat/DatFile.cs b/SabreTools.Helper/Objects/Dat/DatFile.cs index 869234c5..674d726f 100644 --- a/SabreTools.Helper/Objects/Dat/DatFile.cs +++ b/SabreTools.Helper/Objects/Dat/DatFile.cs @@ -1218,10 +1218,13 @@ namespace SabreTools.Helper case OutputFormat.DOSCenter: ParseCMP(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean); break; + case OutputFormat.Logiqx: + ParseLogiqx(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean, softlist); + break; case OutputFormat.OfflineList: case OutputFormat.SabreDat: case OutputFormat.SoftwareList: - ParseXML(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean, softlist); + ParseGenericXML(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean, softlist); break; case OutputFormat.RedumpMD5: ParseRedumpMD5(filename, sysid, srcid, romname, md5, trim, single, root, logger, clean); @@ -1235,9 +1238,6 @@ namespace SabreTools.Helper case OutputFormat.RomCenter: ParseRC(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, clean); break; - case OutputFormat.Xml: - ParseXMLString(filename, sysid, srcid, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, logger, keep, clean, softlist); - break; default: return; } @@ -1857,321 +1857,6 @@ namespace SabreTools.Helper sr.Dispose(); } - /// - /// Parse a Redump MD5 and return all found games and roms within - /// - /// Name of the file to be parsed - /// System ID for the DAT - /// Source ID for the DAT - /// Name of the rom to match (can use asterisk-partials) - /// MD5 of the rom to match (can use asterisk-partials) - /// True if we are supposed to trim names to NTFS length, false otherwise - /// True if all games should be replaced by '!', false otherwise - /// String representing root directory to compare against for length calculation - /// Logger object for console and/or file output - /// True if game names are sanitized, false otherwise (default) - private void ParseRedumpMD5( - // Standard Dat parsing - string filename, - int sysid, - int srcid, - - // Rom filtering - string romname, - string md5, - - // Rom renaming - bool trim, - bool single, - string root, - - // Miscellaneous - Logger logger, - bool clean) - { - // Open a file reader - Encoding enc = Style.GetEncoding(filename); - StreamReader sr = new StreamReader(File.OpenRead(filename), enc); - - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - - Rom rom = new Rom(line.Split(' ')[1].Replace("*", String.Empty), -1, null, line.Split(' ')[0], null, ItemStatus.None, null, - Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); - - // Now process and add the rom - string key = ""; - ParseAddHelper(rom, null, romname, null, -1, -1, -1, null, md5, null, ItemStatus.NULL, trim, single, root, clean, logger, out key); - } - - sr.Dispose(); - } - - /// - /// Parse a Redump SFV and return all found games and roms within - /// - /// Name of the file to be parsed - /// System ID for the DAT - /// Source ID for the DAT - /// Name of the rom to match (can use asterisk-partials) - /// CRC of the rom to match (can use asterisk-partials) - /// True if we are supposed to trim names to NTFS length, false otherwise - /// True if all games should be replaced by '!', false otherwise - /// String representing root directory to compare against for length calculation - /// Logger object for console and/or file output - /// True if game names are sanitized, false otherwise (default) - private void ParseRedumpSFV( - // Standard Dat parsing - string filename, - int sysid, - int srcid, - - // Rom filtering - string romname, - string crc, - - // Rom renaming - bool trim, - bool single, - string root, - - // Miscellaneous - Logger logger, - bool clean) - { - // Open a file reader - Encoding enc = Style.GetEncoding(filename); - StreamReader sr = new StreamReader(File.OpenRead(filename), enc); - - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - - Rom rom = new Rom(line.Split(' ')[0], -1, line.Split(' ')[1], null, null, ItemStatus.None, null, - Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); - - // Now process and add the rom - string key = ""; - ParseAddHelper(rom, null, romname, null, -1, -1, -1, crc, null, null, ItemStatus.NULL, trim, single, root, clean, logger, out key); - } - - sr.Dispose(); - } - - /// - /// Parse a Redump SHA-1 and return all found games and roms within - /// - /// Name of the file to be parsed - /// System ID for the DAT - /// Source ID for the DAT - /// Name of the rom to match (can use asterisk-partials) - /// SHA-1 of the rom to match (can use asterisk-partials) - /// True if we are supposed to trim names to NTFS length, false otherwise - /// True if all games should be replaced by '!', false otherwise - /// String representing root directory to compare against for length calculation - /// Logger object for console and/or file output - /// True if game names are sanitized, false otherwise (default) - private void ParseRedumpSHA1( - // Standard Dat parsing - string filename, - int sysid, - int srcid, - - // Rom filtering - string romname, - string sha1, - - // Rom renaming - bool trim, - bool single, - string root, - - // Miscellaneous - Logger logger, - bool clean) - { - // Open a file reader - Encoding enc = Style.GetEncoding(filename); - StreamReader sr = new StreamReader(File.OpenRead(filename), enc); - - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - - Rom rom = new Rom(line.Split(' ')[1].Replace("*", String.Empty), -1, null, null, line.Split(' ')[0], ItemStatus.None, null, - Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); - - // Now process and add the rom - string key = ""; - ParseAddHelper(rom, null, romname, null, -1, -1, -1, null, null, sha1, ItemStatus.NULL, trim, single, root, clean, logger, out key); - } - - sr.Dispose(); - } - - /// - /// Parse a RomCenter DAT and return all found games and roms within - /// - /// Name of the file to be parsed - /// System ID for the DAT - /// Source ID for the DAT - /// Name of the game to match (can use asterisk-partials) - /// Name of the rom to match (can use asterisk-partials) - /// Type of the rom to match - /// Find roms greater than or equal to this size - /// Find roms less than or equal to this size - /// Find roms equal to this size - /// CRC of the rom to match (can use asterisk-partials) - /// MD5 of the rom to match (can use asterisk-partials) - /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with the given status - /// True if we are supposed to trim names to NTFS length, false otherwise - /// True if all games should be replaced by '!', false otherwise - /// String representing root directory to compare against for length calculation - /// Logger object for console and/or file output - /// True if game names are sanitized, false otherwise (default) - private void ParseRC( - // Standard Dat parsing - string filename, - int sysid, - int srcid, - - // Rom filtering - string gamename, - string romname, - string romtype, - long sgt, - long slt, - long seq, - string crc, - string md5, - string sha1, - ItemStatus itemStatus, - - // Rom renaming - bool trim, - bool single, - string root, - - // Miscellaneous - Logger logger, - bool clean) - { - // Open a file reader - Encoding enc = Style.GetEncoding(filename); - StreamReader sr = new StreamReader(File.OpenRead(filename), enc); - - string blocktype = ""; - while (!sr.EndOfStream) - { - string line = sr.ReadLine(); - - // If the line is the start of the credits section - if (line.ToLowerInvariant().Contains("[credits]")) - { - blocktype = "credits"; - } - // If the line is the start of the dat section - else if (line.ToLowerInvariant().Contains("[dat]")) - { - blocktype = "dat"; - } - // If the line is the start of the emulator section - else if (line.ToLowerInvariant().Contains("[emulator]")) - { - blocktype = "emulator"; - } - // If the line is the start of the game section - else if (line.ToLowerInvariant().Contains("[games]")) - { - blocktype = "games"; - } - // Otherwise, it's not a section and it's data, so get out all data - else - { - // If we have an author - if (line.StartsWith("author=")) - { - Author = (String.IsNullOrEmpty(Author) ? line.Split('=')[1] : Author); - } - // If we have one of the three version tags - else if (line.StartsWith("version=")) - { - switch (blocktype) - { - case "credits": - Version = (String.IsNullOrEmpty(Version) ? line.Split('=')[1] : Version); - break; - case "emulator": - Description = (String.IsNullOrEmpty(Description) ? line.Split('=')[1] : Description); - break; - } - } - // If we have a comment - else if (line.StartsWith("comment=")) - { - Comment = (String.IsNullOrEmpty(Comment) ? line.Split('=')[1] : Comment); - } - // If we have the split flag - else if (line.StartsWith("split=")) - { - int split = 0; - if (Int32.TryParse(line.Split('=')[1], out split)) - { - if (split == 1) - { - ForceMerging = ForceMerging.Split; - } - } - } - // If we have the merge tag - else if (line.StartsWith("merge=")) - { - int merge = 0; - if (Int32.TryParse(line.Split('=')[1], out merge)) - { - if (merge == 1) - { - ForceMerging = ForceMerging.Full; - } - } - } - // If we have the refname tag - else if (line.StartsWith("refname=")) - { - Name = (String.IsNullOrEmpty(Name) ? line.Split('=')[1] : Name); - } - // If we have a rom - else if (line.StartsWith("¬")) - { - /* - The rominfo order is as follows: - 1 - parent name - 2 - parent description - 3 - game name - 4 - game description - 5 - rom name - 6 - rom crc - 7 - rom size - 8 - romof name - 9 - merge name - */ - string[] rominfo = line.Split('¬'); - - Rom rom = new Rom(rominfo[5], Int64.Parse(rominfo[7]), rominfo[6], null, null, ItemStatus.None, null, rominfo[3], null, - rominfo[4], null, null, rominfo[8], rominfo[1], null, null, false, null, null, sysid, null, srcid, null); - - // Now process and add the rom - string key = ""; - ParseAddHelper(rom, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key); - } - } - } - - sr.Dispose(); - } - /// /// Parse an XML DAT (Logiqx, OfflineList, SabreDAT, and Software List) and return all found games and roms within /// @@ -2195,7 +1880,7 @@ namespace SabreTools.Helper /// True if full pathnames are to be kept, false otherwise (default) /// True if game names are sanitized, false otherwise (default) /// True if SL XML names should be kept, false otherwise (default) - private void ParseXML( + private void ParseGenericXML( // Standard Dat parsing string filename, int sysid, @@ -3111,7 +2796,7 @@ namespace SabreTools.Helper /// True if game names are sanitized, false otherwise (default) /// True if SL XML names should be kept, false otherwise (default) /// This version does not fully support OL or SabreDAT - private void ParseXMLString( + private void ParseLogiqx( // Standard Dat parsing string filename, int sysid, @@ -3165,7 +2850,7 @@ namespace SabreTools.Helper // Handle MAME listxml since they're halfway between a SL and a Logiqx XML else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); if (attribs.ContainsKey("build")) { @@ -3177,7 +2862,7 @@ namespace SabreTools.Helper // New software lists have this behavior else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); if (attribs.ContainsKey("name")) { @@ -3230,14 +2915,14 @@ namespace SabreTools.Helper } } } - + // Handle M1 DATs since they're 99% the same as a SL DAT else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); if (attribs.ContainsKey("version")) { @@ -3318,7 +3003,7 @@ namespace SabreTools.Helper Author = (String.IsNullOrEmpty(Author) ? matched[2].Value : Author); // Special cases for SabreDAT - Dictionary attribs = GetAttributes(matched[1].Value); + Dictionary attribs = GetLogiqxAttributes(matched[1].Value); if (attribs.ContainsKey("email")) { Email = (String.IsNullOrEmpty(Email) ? attribs["email"] : Email); @@ -3356,7 +3041,7 @@ namespace SabreTools.Helper } else if (matched[1].Value.StartsWith("clrmamepro") || matched[1].Value.StartsWith("romcenter")) { - Dictionary attribs = GetAttributes(matched[1].Value); + Dictionary attribs = GetLogiqxAttributes(matched[1].Value); if (attribs.ContainsKey("header")) { Header = (String.IsNullOrEmpty(Header) ? attribs["header"].ToString() : Header); @@ -3416,7 +3101,7 @@ namespace SabreTools.Helper if (line.StartsWith("flag")) { - Dictionary attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); if (attribs.ContainsKey("name") && attribs.ContainsKey("value")) { @@ -3480,7 +3165,7 @@ namespace SabreTools.Helper bool isbios = false; // Get the game information - Dictionary gameattribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary gameattribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); string tempname = (gameattribs.ContainsKey("name") ? gameattribs["name"] : ""); string sourcefile = (gameattribs.ContainsKey("sourcefile") ? gameattribs["sourcefile"] : ""); @@ -3530,7 +3215,7 @@ namespace SabreTools.Helper // Now for the different file types else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); Archive item = new Archive((attribs.ContainsKey("name") ? attribs["name"] : ""), tempname, @@ -3556,7 +3241,7 @@ namespace SabreTools.Helper } else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); bool @default = false; if (attribs.ContainsKey("default")) @@ -3598,7 +3283,7 @@ namespace SabreTools.Helper } else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); ItemStatus its = ItemStatus.None; if (attribs.ContainsKey("flags")) @@ -3696,7 +3381,7 @@ namespace SabreTools.Helper } else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); bool @default = false; if (attribs.ContainsKey("default")) @@ -3740,7 +3425,7 @@ namespace SabreTools.Helper } else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); ItemStatus its = ItemStatus.None; if (attribs.ContainsKey("flags")) @@ -3860,7 +3545,7 @@ namespace SabreTools.Helper } else if (line.StartsWith(" attribs = GetAttributes(line.Substring(1, line.Length - 3)); + Dictionary attribs = GetLogiqxAttributes(line.Substring(1, line.Length - 3)); Sample item = new Sample((attribs.ContainsKey("name") ? attribs["name"] : ""), tempname, @@ -3907,7 +3592,7 @@ namespace SabreTools.Helper /// /// Opening tag to be parsed /// Mapping of attribute to values - private Dictionary GetAttributes(string line) + private Dictionary GetLogiqxAttributes(string line) { Dictionary attribs = new Dictionary(); @@ -3979,6 +3664,321 @@ namespace SabreTools.Helper return attribs; } + /// + /// Parse a Redump MD5 and return all found games and roms within + /// + /// Name of the file to be parsed + /// System ID for the DAT + /// Source ID for the DAT + /// Name of the rom to match (can use asterisk-partials) + /// MD5 of the rom to match (can use asterisk-partials) + /// True if we are supposed to trim names to NTFS length, false otherwise + /// True if all games should be replaced by '!', false otherwise + /// String representing root directory to compare against for length calculation + /// Logger object for console and/or file output + /// True if game names are sanitized, false otherwise (default) + private void ParseRedumpMD5( + // Standard Dat parsing + string filename, + int sysid, + int srcid, + + // Rom filtering + string romname, + string md5, + + // Rom renaming + bool trim, + bool single, + string root, + + // Miscellaneous + Logger logger, + bool clean) + { + // Open a file reader + Encoding enc = Style.GetEncoding(filename); + StreamReader sr = new StreamReader(File.OpenRead(filename), enc); + + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + Rom rom = new Rom(line.Split(' ')[1].Replace("*", String.Empty), -1, null, line.Split(' ')[0], null, ItemStatus.None, null, + Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); + + // Now process and add the rom + string key = ""; + ParseAddHelper(rom, null, romname, null, -1, -1, -1, null, md5, null, ItemStatus.NULL, trim, single, root, clean, logger, out key); + } + + sr.Dispose(); + } + + /// + /// Parse a Redump SFV and return all found games and roms within + /// + /// Name of the file to be parsed + /// System ID for the DAT + /// Source ID for the DAT + /// Name of the rom to match (can use asterisk-partials) + /// CRC of the rom to match (can use asterisk-partials) + /// True if we are supposed to trim names to NTFS length, false otherwise + /// True if all games should be replaced by '!', false otherwise + /// String representing root directory to compare against for length calculation + /// Logger object for console and/or file output + /// True if game names are sanitized, false otherwise (default) + private void ParseRedumpSFV( + // Standard Dat parsing + string filename, + int sysid, + int srcid, + + // Rom filtering + string romname, + string crc, + + // Rom renaming + bool trim, + bool single, + string root, + + // Miscellaneous + Logger logger, + bool clean) + { + // Open a file reader + Encoding enc = Style.GetEncoding(filename); + StreamReader sr = new StreamReader(File.OpenRead(filename), enc); + + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + Rom rom = new Rom(line.Split(' ')[0], -1, line.Split(' ')[1], null, null, ItemStatus.None, null, + Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); + + // Now process and add the rom + string key = ""; + ParseAddHelper(rom, null, romname, null, -1, -1, -1, crc, null, null, ItemStatus.NULL, trim, single, root, clean, logger, out key); + } + + sr.Dispose(); + } + + /// + /// Parse a Redump SHA-1 and return all found games and roms within + /// + /// Name of the file to be parsed + /// System ID for the DAT + /// Source ID for the DAT + /// Name of the rom to match (can use asterisk-partials) + /// SHA-1 of the rom to match (can use asterisk-partials) + /// True if we are supposed to trim names to NTFS length, false otherwise + /// True if all games should be replaced by '!', false otherwise + /// String representing root directory to compare against for length calculation + /// Logger object for console and/or file output + /// True if game names are sanitized, false otherwise (default) + private void ParseRedumpSHA1( + // Standard Dat parsing + string filename, + int sysid, + int srcid, + + // Rom filtering + string romname, + string sha1, + + // Rom renaming + bool trim, + bool single, + string root, + + // Miscellaneous + Logger logger, + bool clean) + { + // Open a file reader + Encoding enc = Style.GetEncoding(filename); + StreamReader sr = new StreamReader(File.OpenRead(filename), enc); + + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + Rom rom = new Rom(line.Split(' ')[1].Replace("*", String.Empty), -1, null, null, line.Split(' ')[0], ItemStatus.None, null, + Path.GetFileNameWithoutExtension(filename), null, null, null, null, null, null, null, null, false, null, null, sysid, null, srcid, null); + + // Now process and add the rom + string key = ""; + ParseAddHelper(rom, null, romname, null, -1, -1, -1, null, null, sha1, ItemStatus.NULL, trim, single, root, clean, logger, out key); + } + + sr.Dispose(); + } + + /// + /// Parse a RomCenter DAT and return all found games and roms within + /// + /// Name of the file to be parsed + /// System ID for the DAT + /// Source ID for the DAT + /// Name of the game to match (can use asterisk-partials) + /// Name of the rom to match (can use asterisk-partials) + /// Type of the rom to match + /// Find roms greater than or equal to this size + /// Find roms less than or equal to this size + /// Find roms equal to this size + /// CRC of the rom to match (can use asterisk-partials) + /// MD5 of the rom to match (can use asterisk-partials) + /// SHA-1 of the rom to match (can use asterisk-partials) + /// Select roms with the given status + /// True if we are supposed to trim names to NTFS length, false otherwise + /// True if all games should be replaced by '!', false otherwise + /// String representing root directory to compare against for length calculation + /// Logger object for console and/or file output + /// True if game names are sanitized, false otherwise (default) + private void ParseRC( + // Standard Dat parsing + string filename, + int sysid, + int srcid, + + // Rom filtering + string gamename, + string romname, + string romtype, + long sgt, + long slt, + long seq, + string crc, + string md5, + string sha1, + ItemStatus itemStatus, + + // Rom renaming + bool trim, + bool single, + string root, + + // Miscellaneous + Logger logger, + bool clean) + { + // Open a file reader + Encoding enc = Style.GetEncoding(filename); + StreamReader sr = new StreamReader(File.OpenRead(filename), enc); + + string blocktype = ""; + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + // If the line is the start of the credits section + if (line.ToLowerInvariant().Contains("[credits]")) + { + blocktype = "credits"; + } + // If the line is the start of the dat section + else if (line.ToLowerInvariant().Contains("[dat]")) + { + blocktype = "dat"; + } + // If the line is the start of the emulator section + else if (line.ToLowerInvariant().Contains("[emulator]")) + { + blocktype = "emulator"; + } + // If the line is the start of the game section + else if (line.ToLowerInvariant().Contains("[games]")) + { + blocktype = "games"; + } + // Otherwise, it's not a section and it's data, so get out all data + else + { + // If we have an author + if (line.StartsWith("author=")) + { + Author = (String.IsNullOrEmpty(Author) ? line.Split('=')[1] : Author); + } + // If we have one of the three version tags + else if (line.StartsWith("version=")) + { + switch (blocktype) + { + case "credits": + Version = (String.IsNullOrEmpty(Version) ? line.Split('=')[1] : Version); + break; + case "emulator": + Description = (String.IsNullOrEmpty(Description) ? line.Split('=')[1] : Description); + break; + } + } + // If we have a comment + else if (line.StartsWith("comment=")) + { + Comment = (String.IsNullOrEmpty(Comment) ? line.Split('=')[1] : Comment); + } + // If we have the split flag + else if (line.StartsWith("split=")) + { + int split = 0; + if (Int32.TryParse(line.Split('=')[1], out split)) + { + if (split == 1) + { + ForceMerging = ForceMerging.Split; + } + } + } + // If we have the merge tag + else if (line.StartsWith("merge=")) + { + int merge = 0; + if (Int32.TryParse(line.Split('=')[1], out merge)) + { + if (merge == 1) + { + ForceMerging = ForceMerging.Full; + } + } + } + // If we have the refname tag + else if (line.StartsWith("refname=")) + { + Name = (String.IsNullOrEmpty(Name) ? line.Split('=')[1] : Name); + } + // If we have a rom + else if (line.StartsWith("¬")) + { + /* + The rominfo order is as follows: + 1 - parent name + 2 - parent description + 3 - game name + 4 - game description + 5 - rom name + 6 - rom crc + 7 - rom size + 8 - romof name + 9 - merge name + */ + string[] rominfo = line.Split('¬'); + + Rom rom = new Rom(rominfo[5], Int64.Parse(rominfo[7]), rominfo[6], null, null, ItemStatus.None, null, rominfo[3], null, + rominfo[4], null, null, rominfo[8], rominfo[1], null, null, false, null, null, sysid, null, srcid, null); + + // Now process and add the rom + string key = ""; + ParseAddHelper(rom, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, clean, logger, out key); + } + } + } + + sr.Dispose(); + } + /// /// Add a rom to the Dat after checking /// @@ -4192,7 +4192,7 @@ namespace SabreTools.Helper // If the DAT has no output format, default to XML if (OutputFormat == 0) { - OutputFormat = OutputFormat.Xml; + OutputFormat = OutputFormat.Logiqx; } // Make sure that the three essential fields are filled in @@ -4503,7 +4503,7 @@ namespace SabreTools.Helper (ForceNodump == ForceNodump.Required ? " forceitemStatus=\"required\"" : "") + " />\n\n"; break; - case OutputFormat.Xml: + case OutputFormat.Logiqx: header = "\n" + "\n\n" + "\n" + @@ -4602,7 +4602,7 @@ namespace SabreTools.Helper + (rom.Year != null ? "\t\t" + HttpUtility.HtmlEncode(rom.Year) + "\n" : "") + "\t\t\n"; break; - case OutputFormat.Xml: + case OutputFormat.Logiqx: state += "\t>(), diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index d53b2e35..f220351c 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -286,7 +286,7 @@ namespace SabreTools break; case "-ox": case "--output-xml": - outputFormat |= OutputFormat.Xml; + outputFormat |= OutputFormat.Logiqx; break; case "-q": case "--quotes":