private void LoadRomFromDat(DatDir parentDir, XmlNode romNode) { if (romNode.Attributes == null) { return; } XmlNode name = romNode.Attributes.GetNamedItem("name"); string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag")); if (name != null) { DatFile dRom = new DatFile(DatFileType.UnSet) { Name = VarFix.String(name), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")) }; _indexContinue = parentDir.ChildAdd(dRom); } else if (loadflag.ToLower() == "continue") { DatFile tRom = (DatFile)parentDir.Child(_indexContinue); tRom.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } }
private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode) { if (romNode.Attributes == null) { return; } XmlNode name = romNode.Attributes.GetNamedItem("name"); string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag")); if (name != null) { RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(name); rvRom.Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")); rvRom.CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8); rvRom.SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40); rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")); _indexContinue = rvGame.AddRom(rvRom); } else if (loadflag.ToLower() == "continue") { RvRom tROM = rvGame.Roms[_indexContinue]; tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } else if (loadflag.ToLower() == "ignore") { RvRom tROM = rvGame.Roms[_indexContinue]; tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } }
private static bool LoadRomFromDat(RvGame rvGame) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat("( not found after rom", DatFileLoader.Filename); return(false); } DatFileLoader.Gn(); if (DatFileLoader.Next.ToLower() != "name") { DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename); return(false); } RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "size": rvRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "crc": rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break; case "sha1": rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "md5": rvRom.MD5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "merge": rvRom.Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "flags": rvRom.Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "date": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "bios": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "region": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "offs": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "nodump": rvRom.Status = "nodump"; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in rom", DatFileLoader.Filename); DatFileLoader.Gn(); break; } } rvGame.AddRom(rvRom); return(true); }
private bool LoadFileFromDat(DatFileLoader dfl, DatDir parentDir) { if (dfl.Next != "(") { _errorReport?.Invoke(dfl.Filename, "( not found after file, on line " + dfl.LineNumber); return(false); } dfl.Gn(); if (dfl.Next.ToLower() != "name") { _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber); return(false); } DatFile dRom = new DatFile(DatFileType.UnSet) { Name = dfl.GnNameToSize() }; dfl.Gn(); while (dfl.Next != ")") { switch (dfl.Next.ToLower()) { case "size": dRom.Size = VarFix.ULong(dfl.Gn()); dfl.Gn(); break; case "crc": dRom.CRC = VarFix.CleanMD5SHA1(dfl.Gn(), 8); dfl.Gn(); break; case "date": dRom.Date = dfl.Gn() + " " + dfl.Gn(); dfl.Gn(); break; default: _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber); dfl.Gn(); break; } } parentDir.ChildAdd(dRom); return(true); }
private static bool LoadRomFromDat(ref RvDir tGame, FileType thisFileType) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadRomFromDat_not_found_after_rom, DatFileLoader.Filename); return(false); } string line = DatFileLoader.GnRest(); string linelc = line.ToLower(); int posName = linelc.IndexOf("name ", StringComparison.Ordinal); int posSize = linelc.IndexOf(" size ", posName + 5, StringComparison.Ordinal); int posDate = linelc.IndexOf(" date ", posSize + 6, StringComparison.Ordinal); int posCrc = linelc.IndexOf(" crc ", posDate + 6, StringComparison.Ordinal); int posEnd = linelc.IndexOf(" )", posCrc + 5, StringComparison.Ordinal); if (posName < 0 || posSize < 0 || posDate < 0 || posCrc < 0 || posEnd < 0) { DatFileLoader.Gn(); return(false); } string name = line.Substring(posName + 5, posSize - (posName + 5)); string size = line.Substring(posSize + 6, posDate - (posSize + 6)); //string date = line.Substring(posDate + 6, posCrc - (posDate + 6)); string crc = line.Substring(posCrc + 5, posEnd - (posCrc + 5)); RvFile tRom = new RvFile(thisFileType) { Dat = tGame.Dat, Name = VarFix.CleanFullFileName(name.Trim()), Size = VarFix.ULong(size.Trim()), CRC = VarFix.CleanMD5SHA1(crc.Trim(), 8) }; if (tRom.Size != null) { tRom.FileStatusSet(FileStatus.SizeFromDAT); } if (tRom.CRC != null) { tRom.FileStatusSet(FileStatus.CRCFromDAT); } tGame.ChildAdd(tRom); return(true); }
private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode, FileType thisFileType) { if (romNode.Attributes == null) { return; } XmlNode name = romNode.Attributes.GetNamedItem("name"); string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag")); if (name != null) { RvFile tRom = new RvFile(thisFileType) // changed { Name = VarFix.CleanFullFileName(name), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")), Dat = tGame.Dat }; if (tRom.Size != null) { tRom.FileStatusSet(FileStatus.SizeFromDAT); } if (tRom.CRC != null) { tRom.FileStatusSet(FileStatus.CRCFromDAT); } if (tRom.SHA1 != null) { tRom.FileStatusSet(FileStatus.SHA1FromDAT); } _indexContinue = tGame.ChildAdd(tRom); } else if (loadflag.ToLower() == "continue") { RvFile tZippedFile = (RvFile)tGame.Child(_indexContinue); tZippedFile.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size")); } }
private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode) { if (romNode.Attributes == null) { return; } RvRom rvRom = new RvRom(); rvRom.Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")); rvRom.Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")); rvRom.CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8); rvRom.SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40); rvRom.MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32); rvRom.Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")); rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")); rvGame.AddRom(rvRom); }
private static void LoadRomFromDat(DatDir parentDir, XmlNode romNode) { if (romNode.Attributes == null) { return; } DatFile rvRom = new DatFile(DatFileType.UnSet) { Name = VarFix.String(romNode.Attributes.GetNamedItem("name")), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32), Merge = VarFix.String(romNode.Attributes.GetNamedItem("merge")), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")), Region = VarFix.ToLower(romNode.Attributes.GetNamedItem("region")) }; parentDir.ChildAdd(rvRom); }
private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode, HeaderFileType datFileType) { if (romNode.Attributes == null) { return; } RvRom rvRom = new RvRom { AltType = datFileType, Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32), Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")) }; rvGame.AddRom(rvRom); }
private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode, FileType thisFileType) { if (romNode.Attributes == null) { return; } RvFile tRom = new RvFile(thisFileType) { Dat = tGame.Dat, Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")), CRC = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8), SHA1 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), MD5 = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32), Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")) }; if (tRom.Size != null) { tRom.FileStatusSet(FileStatus.SizeFromDAT); } if (tRom.CRC != null) { tRom.FileStatusSet(FileStatus.CRCFromDAT); } if (tRom.SHA1 != null) { tRom.FileStatusSet(FileStatus.SHA1FromDAT); } if (tRom.MD5 != null) { tRom.FileStatusSet(FileStatus.MD5FromDAT); } tGame.ChildAdd(tRom); }
private bool LoadRomFromDat(DatFileLoader dfl, DatDir parentDir) { dfl.Gn(); if (dfl.Next != "(") { _errorReport?.Invoke(dfl.Filename, "( not found after rom, on line " + dfl.LineNumber); return(false); } dfl.Gn(); if (dfl.Next.ToLower() != "name") { _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber); return(false); } DatFile dRom = new DatFile(DatFileType.UnSet) { Name = dfl.Gn() }; dfl.Gn(); while (dfl.Next != ")") { switch (dfl.Next.ToLower()) { case "size": dRom.Size = VarFix.ULong(dfl.Gn()); break; case "crc": dRom.CRC = VarFix.CleanMD5SHA1(dfl.Gn(), 8); break; case "sha1": dRom.SHA1 = VarFix.CleanMD5SHA1(dfl.Gn(), 40); break; case "md5": dRom.MD5 = VarFix.CleanMD5SHA1(dfl.Gn(), 32); break; case "merge": dRom.Merge = VarFix.String(dfl.Gn()); break; case "flags": dRom.Status = VarFix.ToLower(dfl.Gn()); break; case "date": dfl.Gn(); break; case "bios": dfl.Gn(); break; case "region": dfl.Gn(); break; case "offs": dfl.Gn(); break; case "nodump": dRom.Status = "nodump"; break; case "baddump": dRom.Status = "baddump"; break; default: _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber); break; } dfl.Gn(); } parentDir.ChildAdd(dRom); return(true); }
private static bool LoadRomFromDat(ref RvDir tGame, FileType thisFileType) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadRomFromDat_not_found_after_rom, DatFileLoader.Filename); return(false); } DatFileLoader.Gn(); if (DatFileLoader.Next.ToLower() != "name") { DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename); return(false); } string filename = VarFix.CleanFullFileName(DatFileLoader.Gn()); RvFile tRom = new RvFile(thisFileType) { Name = filename }; DatFileLoader.Gn(); tRom.Dat = tGame.Dat; while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "size": tRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "crc": tRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break; case "sha1": tRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "md5": tRom.MD5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "merge": tRom.Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "flags": tRom.Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "date": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "bios": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "region": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "offs": DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "nodump": tRom.Status = "nodump"; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadRomFromDat_not_known_in_rom, DatFileLoader.Filename); DatFileLoader.Gn(); break; } } if (tRom.Size != null) { tRom.FileStatusSet(FileStatus.SizeFromDAT); } if (tRom.CRC != null) { tRom.FileStatusSet(FileStatus.CRCFromDAT); } if (tRom.SHA1 != null) { tRom.FileStatusSet(FileStatus.SHA1FromDAT); } if (tRom.MD5 != null) { tRom.FileStatusSet(FileStatus.MD5FromDAT); } tGame.ChildAdd(tRom); return(true); }
private static bool LoadGame(DatFileLoader dfl, DatDir parentDir, ReportError errorReport) { if (dfl.Next.ToLower() != "[games]" && dfl.Next.ToLower() != "[resources]") { errorReport?.Invoke(dfl.Filename, "Looking for [GAMES] but found " + dfl.Next + " , " + dfl.LineNumber); return(false); } while (!dfl.EndOfStream()) { string line = dfl.Gn(); if (line.Substring(0, 1) == "[") { return(true); } string[] parts = line.Split('¬'); // 1 parent name = clone of // 2 parent description = description (from parent) // 3 game name = name (game) // 4 game description = description // 5 rom name = name (rom) // 6 rom crc = crc // 7 rom size = size // 8 romof name = romof // 9 merge name = merge string ParentName = parts[1]; string ParentDescription = parts[2]; string GameName = parts[3]; string GameDescription = parts[4]; string romName = parts[5]; string romCRC = parts[6]; string romSize = parts[7]; string romOf = parts[8]; string merge = parts[9]; int index; DatDir dDir; DatDir searchDir = new DatDir(DatFileType.Dir) { Name = GameName }; if (parentDir.ChildNameSearch(searchDir, out index) != 0) { dDir = new DatDir(DatFileType.UnSet) { Name = GameName, DGame = new DatGame() }; DatGame dGame = dDir.DGame; dGame.Description = GameDescription; if (ParentName != GameName) { dGame.CloneOf = ParentName; } parentDir.ChildAdd(dDir); } else { dDir = (DatDir)parentDir.Child(index); // need to check everything matches } DatFile dRom = new DatFile(DatFileType.UnSet); dRom.Name = romName; dRom.CRC = VarFix.CleanMD5SHA1(romCRC, 8); dRom.Size = VarFix.ULong(romSize); dRom.Merge = merge; // check romof=ParentName dDir.ChildAdd(dRom); } return(true); }
private static bool LoadRomFromDat(RvGame rvGame, HeaderFileType datFileType) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat("( not found after rom on line " + DatFileLoader.LineNumber, DatFileLoader.Filename); return(false); } DatFileLoader.Gn(); if (DatFileLoader.Next.ToLower() != "name") { DatUpdate.SendAndShowDat("Name not found as first object in ( ) on line " + DatFileLoader.LineNumber, DatFileLoader.Filename); return(false); } RvRom rvRom = new RvRom { Name = VarFix.CleanFullFileName(DatFileLoader.Gn()), AltType = datFileType }; DatFileLoader.Gn(); while (rvRom.CRC == null || rvRom.Size == null || DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "size": rvRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "crc": rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break; case "md5": rvRom.MD5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "sha1": rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "sha256": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "sha384": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "sha512": // No-op until larger hashes are supported DatFileLoader.Gn(); DatFileLoader.Gn(); break; case "date": rvRom.Date = DatFileLoader.Gn(); rvRom.Date += " " + DatFileLoader.Gn(); DatFileLoader.Gn(); break; default: rvRom.Name += " " + DatFileLoader.Next; DatFileLoader.Gn(); break; } } rvGame.AddRom(rvRom); return(true); }