public static List <RvRom> ReadRoms(uint gameId) { if (_commandRvRomReader == null) { _commandRvRomReader = new SQLiteCommand( @"SELECT RomId,name, type, rom.size, rom.crc, rom.sha1, rom.md5, merge,status,putinzip, rom.FileId, files.size as fileSize, files.compressedsize as fileCompressedSize, files.crc as filecrc, files.sha1 as filesha1, files.md5 as filemd5 FROM rom LEFT OUTER JOIN files ON files.FileId=rom.FileId WHERE GameId=@GameId ORDER BY RomId", Program.db.Connection); _commandRvRomReader.Parameters.Add(new SQLiteParameter("GameId")); } List <RvRom> roms = new List <RvRom>(); _commandRvRomReader.Parameters["GameId"].Value = gameId; using (DbDataReader dr = _commandRvRomReader.ExecuteReader()) { while (dr.Read()) { RvRom row = new RvRom { RomId = Convert.ToUInt32(dr["RomId"]), GameId = gameId, Name = dr["name"].ToString(), AltType = VarFix.FixFileType(dr["type"]), Size = VarFix.FixLong(dr["size"]), CRC = VarFix.CleanMD5SHA1(dr["CRC"].ToString(), 8), SHA1 = VarFix.CleanMD5SHA1(dr["SHA1"].ToString(), 40), MD5 = VarFix.CleanMD5SHA1(dr["MD5"].ToString(), 32), Merge = dr["merge"].ToString(), Status = dr["status"].ToString(), PutInZip = (bool)dr["putinzip"], FileId = VarFix.FixLong(dr["FileId"]), FileSize = VarFix.FixLong(dr["fileSize"]), FileCompressedSize = VarFix.FixLong(dr["fileCompressedSize"]), FileCRC = VarFix.CleanMD5SHA1(dr["fileCRC"].ToString(), 8), FileSHA1 = VarFix.CleanMD5SHA1(dr["fileSHA1"].ToString(), 40), FileMD5 = VarFix.CleanMD5SHA1(dr["fileMD5"].ToString(), 32) }; roms.Add(row); } dr.Close(); } return(roms); }
private static bool LoadRomFromDat(string rootName, HeaderFileType datFileType, out RvRom rvRom, out string game, out string description, out string romof, out string cloneof) { // Set the current out vars to blank for the time being rvRom = new RvRom(); game = ""; description = ""; romof = ""; cloneof = ""; if (!DatFileLoader.Next.Contains("¬")) { DatUpdate.SendAndShowDat("¬ not found in the rom definition on line " + DatFileLoader.LineNumber, DatFileLoader.Filename); return(false); } // Some old RC DATs have this behavior if (DatFileLoader.Next.Contains("¬N¬O")) { DatFileLoader.Next = DatFileLoader.Next.Replace("¬N¬O", "") + "¬¬"; } string[] split = DatFileLoader.Next.Split('¬'); game = split[3]; description = split[4]; romof = split[1]; cloneof = split[1]; rvRom = new RvRom { Name = split[5], CRC = VarFix.CleanMD5SHA1(split[6], 8), Size = Int64.TryParse(split[7], out var temp) ? VarFix.FixLong(split[7]) : null, Merge = split[9], }; return(true); }