public void DBRead(uint datId, bool readGames = false) { SqlRead.Parameters["DatID"].Value = datId; using (SQLiteDataReader dr = SqlRead.ExecuteReader()) { if (dr.Read()) { DatId = datId; DirId = Convert.ToUInt32(dr["DirId"]); Filename = dr["filename"].ToString(); Name = dr["name"].ToString(); RootDir = dr["rootdir"].ToString(); Description = dr["description"].ToString(); Category = dr["category"].ToString(); Version = dr["version"].ToString(); Date = dr["date"].ToString(); Author = dr["author"].ToString(); Email = dr["email"].ToString(); Homepage = dr["homepage"].ToString(); URL = dr["url"].ToString(); Comment = dr["comment"].ToString(); } dr.Close(); } if (readGames) { Games = RvGame.ReadGames(DatId, true); } }
public static void MakeDatZips(object sender, DoWorkEventArgs e) { _bgw = sender as BackgroundWorker; Program.SyncCont = e.Argument as SynchronizationContext; if (Program.SyncCont == null) { _bgw = null; return; } if (!Directory.Exists(_outputdir)) return; if (_treeRow != null) FindDats(_treeRow); else { RvGame tGame = new RvGame(); tGame.DBRead((int)_gameId, true); ExtractGame(tGame, _outputdir); } _bgw.ReportProgress(0, new bgwText("Creating Zips Complete")); _bgw = null; Program.SyncCont = null; }
private static void MakeDB() { ExecuteNonQuery(@"CREATE TABLE IF NOT EXISTS [VERSION] ([Version] INTEGER NOT NULL); INSERT INTO VERSION (version) VALUES (@Version);", "version", DBVersion); ExecuteNonQuery(@" CREATE TABLE IF NOT EXISTS [DIR] ( [DirId] INTEGER PRIMARY KEY NOT NULL, [ParentDirId] INTEGER NULL, [name] NVARCHAR(300) NOT NULL, [fullname] NVARCHAR(300) NOT NULL, [expanded] BOOLEAN DEFAULT 1 NOT NULL, [found] BOOLEAN DEFAULT 1, [RomTotal] INTEGER NULL, [RomGot] iNTEGER NULL, [RomNoDump] INTEGER NULL ); "); RvDat.MakeDB(); RvGame.MakeDB(); RvRom.MakeDB(); RvFile.MakeDB(); }
private static void RvGameReadFromReader(DbDataReader dr, RvGame game) { game.GameId = Convert.ToUInt32(dr["GameId"]); game.DatId = Convert.ToUInt32(dr["DatId"]); game.Name = dr["name"].ToString(); game.Description = dr["description"].ToString(); game.Manufacturer = dr["manufacturer"].ToString(); game.CloneOf = dr["cloneOf"].ToString(); game.RomOf = dr["romof"].ToString(); game.SourceFile = dr["sourcefile"].ToString(); game.IsBios = dr["isbios"].ToString(); game.Board = dr["board"].ToString(); game.Year = dr["year"].ToString(); game.IsTrurip = Convert.ToBoolean(dr["istrurip"]); game.Publisher = dr["publisher"].ToString(); game.Developer = dr["developer"].ToString(); game.Edition = dr["edition"].ToString(); game.Version = dr["version"].ToString(); game.Type = dr["type"].ToString(); game.Media = dr["media"].ToString(); game.Language = dr["language"].ToString(); game.Players = dr["players"].ToString(); game.Ratings = dr["ratings"].ToString(); game.Genre = dr["genre"].ToString(); game.Peripheral = dr["peripheral"].ToString(); game.BarCode = dr["barcode"].ToString(); game.MediaCatalogNumber = dr["mediacatalognumber"].ToString(); }
public static List <RvGame> ReadGames(uint datId, bool readRoms = false) { if (_commandRvGameReadDatGames == null) { _commandRvGameReadDatGames = new SQLiteCommand(@" SELECT GameId, DatId, name, description, manufacturer, cloneof, romof, sourcefile, isbios, board, year, istrurip, publisher, developer, edition, version, type, media, language, players, ratings, genre, peripheral, barcode, mediacatalognumber FROM GAME WHERE DatId=@DatId ORDER BY name", Program.db.Connection); _commandRvGameReadDatGames.Parameters.Add(new SQLiteParameter("DatId")); } List <RvGame> games = new List <RvGame>(); _commandRvGameReadDatGames.Parameters["DatId"].Value = datId; using (DbDataReader dr = _commandRvGameReadDatGames.ExecuteReader()) { while (dr.Read()) { RvGame rvGame = new RvGame(); RvGameReadFromReader(dr, rvGame); games.Add(rvGame); } dr.Close(); } if (readRoms) { foreach (RvGame game in games) { game.Roms = RvRom.ReadRoms(game.GameId); } } return(games); }
public void AddGame(RvGame rvGame) { if (Games == null) { Games = new List <RvGame>(); } Games.Add(rvGame); }
public void AddGame(RvGame rvGame) { if (Games == null) { Games = new List <RvGame>(); } int index; ChildNameSearch(rvGame.Name, out index); Games.Insert(index, rvGame); }
private void MakeDB() { /******** Create Tables ***********/ ExecuteNonQuery(@" CREATE TABLE IF NOT EXISTS [VERSION] ( [Version] INTEGER NOT NULL); INSERT INTO VERSION (version) VALUES (@Version);", "version", DBVersion); RvDir.CreateTable(); RvDat.CreateTable(); RvGame.CreateTable(); RvFile.CreateTable(); RvRom.CreateTable(); }
public static List <RvGame> ReadGames(uint DatId, bool readRoms = false) { List <RvGame> games = new List <RvGame>(); SqlReadGames.Parameters["DatId"].Value = DatId; using (SQLiteDataReader dr = SqlReadGames.ExecuteReader()) { while (dr.Read()) { RvGame rvGame = new RvGame(); rvGame.ReadFromReader(dr, readRoms); games.Add(rvGame); } dr.Close(); } return(games); }
public void DbRead(uint datId, bool readGames = false) { if (_commandRvDatRead == null) { _commandRvDatRead = new SQLiteCommand(@" SELECT DirId,Filename,name,rootdir,description,category,version,date,author,email,homepage,url,comment,mergetype FROM DAT WHERE DatId=@datId ORDER BY Filename", Program.db.Connection); _commandRvDatRead.Parameters.Add(new SQLiteParameter("datId")); } _commandRvDatRead.Parameters["DatID"].Value = datId; using (DbDataReader dr = _commandRvDatRead.ExecuteReader()) { if (dr.Read()) { DatId = datId; DirId = Convert.ToUInt32(dr["DirId"]); Filename = dr["filename"].ToString(); Name = dr["name"].ToString(); RootDir = dr["rootdir"].ToString(); Description = dr["description"].ToString(); Category = dr["category"].ToString(); Version = dr["version"].ToString(); Date = dr["date"].ToString(); Author = dr["author"].ToString(); Email = dr["email"].ToString(); Homepage = dr["homepage"].ToString(); URL = dr["url"].ToString(); Comment = dr["comment"].ToString(); MergeType = dr["mergetype"].ToString(); } dr.Close(); } if (readGames) { Games = RvGame.ReadGames(DatId, true); } }
public void AddGame(RvGame rvGame) { if (Games==null) Games=new List<RvGame>(); Games.Add(rvGame); }
private static bool LoadDiskFromDat(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; } string filename = VarFix.CleanFullFileName(DatFileLoader.Gn()); byte[] sha1; byte[] md5; string Merge; string Status; DatFileLoader.Gn(); while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "sha1": sha1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break; case "md5": md5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break; case "merge": Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "flags": Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break; case "nodump": Status = "nodump"; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in rom", DatFileLoader.Filename); DatFileLoader.Gn(); break; } } return true; }
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 LoadGameFromDat(RvDat rvDat, XmlNode gameNode, string rootDir) { if (gameNode.Attributes == null) return; RvGame rvGame=new RvGame(); rvGame.Name = VarFix.CleanFullFileName(gameNode.Attributes.GetNamedItem("name")); rvGame.RomOf = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("romof")); rvGame.CloneOf = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("cloneof")); rvGame.SampleOf = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("sampleof")); rvGame.Description = VarFix.String(gameNode.SelectSingleNode("description")); rvGame.SourceFile = VarFix.String(gameNode.Attributes.GetNamedItem("sourcefile")); rvGame.IsBios = VarFix.String(gameNode.Attributes.GetNamedItem("isbios")); rvGame.Board = VarFix.String(gameNode.Attributes.GetNamedItem("board")); rvGame.Year = VarFix.String(gameNode.SelectSingleNode("year")); rvGame.Manufacturer = VarFix.String(gameNode.SelectSingleNode("manufacturer")); XmlNode trurip = gameNode.SelectSingleNode("trurip"); if (trurip != null) { rvGame.IsTrurip = true; rvGame.Publisher = VarFix.String(trurip.SelectSingleNode("publisher")); rvGame.Developer = VarFix.String(trurip.SelectSingleNode("developer")); rvGame.Edition = VarFix.String(trurip.SelectSingleNode("edition")); rvGame.Version = VarFix.String(trurip.SelectSingleNode("version")); rvGame.Type = VarFix.String(trurip.SelectSingleNode("type")); rvGame.Media = VarFix.String(trurip.SelectSingleNode("media")); rvGame.Language = VarFix.String(trurip.SelectSingleNode("language")); rvGame.Players = VarFix.String(trurip.SelectSingleNode("players")); rvGame.Ratings = VarFix.String(trurip.SelectSingleNode("ratings")); rvGame.Peripheral = VarFix.String(trurip.SelectSingleNode("peripheral")); rvGame.Genre = VarFix.String(trurip.SelectSingleNode("genre")); rvGame.MediaCatalogNumber = VarFix.String(trurip.SelectSingleNode("mediacatalognumber")); rvGame.BarCode = VarFix.String(trurip.SelectSingleNode("barcode")); } rvGame.Name = IO.Path.Combine(rootDir,rvGame.Name); rvDat.AddGame(rvGame); XmlNodeList romNodeList = gameNode.SelectNodes("rom"); if (romNodeList != null) for (int i = 0; i < romNodeList.Count; i++) LoadRomFromDat(rvGame, romNodeList[i]); XmlNodeList diskNodeList = gameNode.SelectNodes("disk"); if (diskNodeList != null) for (int i = 0; i < diskNodeList.Count; i++) LoadDiskFromDat(rvGame, diskNodeList[i]); }
private static void LoadDiskFromDat(RvGame rvGame, XmlNode romNode) { if (romNode.Attributes == null) return; string Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")) + ".chd"; byte[] SHA1CHD = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40); byte[] MD5CHD = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32); string Merge = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")); string Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")); }
private void UpdateSelectedGame() { RvGame tGame = null; if (_updatingGameGrid) return; if (GameGrid.SelectedRows.Count == 1) { int GameId = (int)GameGrid.SelectedRows[0].Tag; tGame = new RvGame(); tGame.DBRead(GameId); } if (tGame == null) { lblSIName.Visible = false; lblSITName.Visible = false; lblSIDescription.Visible = false; lblSITDescription.Visible = false; lblSIManufacturer.Visible = false; lblSITManufacturer.Visible = false; lblSICloneOf.Visible = false; lblSITCloneOf.Visible = false; lblSIRomOf.Visible = false; lblSITRomOf.Visible = false; lblSIYear.Visible = false; lblSITYear.Visible = false; lblSITotalRoms.Visible = false; lblSITTotalRoms.Visible = false; // Trurip lblSIPublisher.Visible = false; lblSITPublisher.Visible = false; lblSIDeveloper.Visible = false; lblSITDeveloper.Visible = false; lblSIEdition.Visible = false; lblSITEdition.Visible = false; lblSIVersion.Visible = false; lblSITVersion.Visible = false; lblSIType.Visible = false; lblSITType.Visible = false; lblSIMedia.Visible = false; lblSITMedia.Visible = false; lblSILanguage.Visible = false; lblSITLanguage.Visible = false; lblSIPlayers.Visible = false; lblSITPlayers.Visible = false; lblSIRatings.Visible = false; lblSITRatings.Visible = false; lblSIGenre.Visible = false; lblSITGenre.Visible = false; lblSIPeripheral.Visible = false; lblSITPeripheral.Visible = false; lblSIBarCode.Visible = false; lblSITBarCode.Visible = false; lblSIMediaCatalogNumber.Visible = false; lblSITMediaCatalogNumber.Visible = false; return; } lblSIName.Visible = true; lblSITName.Visible = true; lblSITName.Text = GameGrid.SelectedRows[0].Cells[1].Value.ToString(); if (tGame.IsTrurip) { lblSIDescription.Visible = true; lblSITDescription.Visible = true; lblSITDescription.Text = tGame.Description; lblSIManufacturer.Visible = false; lblSITManufacturer.Visible = false; lblSICloneOf.Visible = false; lblSITCloneOf.Visible = false; lblSIRomOf.Visible = false; lblSITRomOf.Visible = false; lblSIYear.Visible = false; lblSITYear.Visible = false; lblSITotalRoms.Visible = false; lblSITTotalRoms.Visible = false; lblSIPublisher.Visible = true; lblSITPublisher.Visible = true; lblSITPublisher.Text = tGame.Publisher; lblSIDeveloper.Visible = true; lblSITDeveloper.Visible = true; lblSITDeveloper.Text = tGame.Developer; lblSIEdition.Visible = true; lblSITEdition.Visible = true; lblSITEdition.Text = tGame.Edition; lblSIVersion.Visible = true; lblSITVersion.Visible = true; lblSITVersion.Text = tGame.Version; lblSIType.Visible = true; lblSITType.Visible = true; lblSITType.Text = tGame.Type; lblSIMedia.Visible = true; lblSITMedia.Visible = true; lblSITMedia.Text = tGame.Media; lblSILanguage.Visible = true; lblSITLanguage.Visible = true; lblSITLanguage.Text = tGame.Language; lblSIPlayers.Visible = true; lblSITPlayers.Visible = true; lblSITPlayers.Text = tGame.Players; lblSIRatings.Visible = true; lblSITRatings.Visible = true; lblSITRatings.Text = tGame.Ratings; lblSIGenre.Visible = true; lblSITGenre.Visible = true; lblSITGenre.Text = tGame.Genre; lblSIPeripheral.Visible = true; lblSITPeripheral.Visible = true; lblSITPeripheral.Text = tGame.Peripheral; lblSIBarCode.Visible = true; lblSITBarCode.Visible = true; lblSITBarCode.Text = tGame.BarCode; lblSIMediaCatalogNumber.Visible = true; lblSITMediaCatalogNumber.Visible = true; lblSITMediaCatalogNumber.Text = tGame.MediaCatalogNumber; } else { lblSIDescription.Visible = true; lblSITDescription.Visible = true; lblSITDescription.Text = tGame.Description; lblSIManufacturer.Visible = true; lblSITManufacturer.Visible = true; lblSITManufacturer.Text = tGame.Manufacturer; lblSICloneOf.Visible = true; lblSITCloneOf.Visible = true; lblSITCloneOf.Text = tGame.CloneOf; lblSIRomOf.Visible = true; lblSITRomOf.Visible = true; lblSITRomOf.Text = tGame.RomOf; lblSIYear.Visible = true; lblSITYear.Visible = true; lblSITYear.Text = tGame.Year; lblSITotalRoms.Visible = true; lblSITTotalRoms.Visible = true; lblSIPublisher.Visible = false; lblSITPublisher.Visible = false; lblSIDeveloper.Visible = false; lblSITDeveloper.Visible = false; lblSIEdition.Visible = false; lblSITEdition.Visible = false; lblSIVersion.Visible = false; lblSITVersion.Visible = false; lblSIType.Visible = false; lblSITType.Visible = false; lblSIMedia.Visible = false; lblSITMedia.Visible = false; lblSILanguage.Visible = false; lblSITLanguage.Visible = false; lblSIPlayers.Visible = false; lblSITPlayers.Visible = false; lblSIRatings.Visible = false; lblSITRatings.Visible = false; lblSIGenre.Visible = false; lblSITGenre.Visible = false; lblSIPeripheral.Visible = false; lblSITPeripheral.Visible = false; lblSIBarCode.Visible = false; lblSITBarCode.Visible = false; lblSIMediaCatalogNumber.Visible = false; lblSITMediaCatalogNumber.Visible = false; } UpdateRomGrid(tGame.GameId); }
private static bool LoadGameFromDat(RvDat rvDat, string rootdir) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat("( not found after game", DatFileLoader.Filename); return false; } DatFileLoader.Gn(); string snext = DatFileLoader.Next.ToLower(); string pathextra = ""; if (snext == "rebuildto") { pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); snext = DatFileLoader.Next.ToLower(); } if (snext != "name") { DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename); return false; } string name = VarFix.CleanFullFileName(DatFileLoader.GnRest()); if (!String.IsNullOrEmpty(pathextra)) name = pathextra + "/" + name; DatFileLoader.Gn(); RvGame rvGame = new RvGame(); rvGame.Name = name; while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { case "romof": rvGame.RomOf = VarFix.CleanFileName(DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "description": rvGame.Description = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "sourcefile": rvGame.SourceFile = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "cloneof": rvGame.CloneOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "sampleof": rvGame.SampleOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "board": rvGame.Board = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "year": rvGame.Year = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "manufacturer": rvGame.Manufacturer = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "serial": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "rebuildto": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "sample": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "biosset": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "chip": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "video": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "sound": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "input": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "dipswitch": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "driver": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "rom": DatFileLoader.Gn(); if (!LoadRomFromDat(rvGame)) return false; DatFileLoader.Gn(); break; case "disk": DatFileLoader.Gn(); if (!LoadDiskFromDat(rvGame)) return false; DatFileLoader.Gn(); break; case "archive": DatFileLoader.Gn(); if (!LoadArchiveFromDat()) return false; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in game", DatFileLoader.Filename); DatFileLoader.Gn(); break; } } rvDat.AddGame(rvGame); return true; }
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 static void ExtractGame(RvGame tGame, string outDir) { if (buffer == null) buffer = new byte[BufferSize]; ZipReturn zr; bool romGot = false; for (int rIndex = 0; rIndex < tGame.Roms.Count; rIndex++) { if (tGame.Roms[rIndex].FileId != null) { romGot = true; break; } } if (!romGot) return; // export the rom; ZipFile zipOut = new ZipFile(); string filename = Path.Combine(outDir, tGame.Name + ".zip"); filename = filename.Replace(@"/", @"\"); if (!Directory.Exists(filename)) { string dir = Path.GetDirectoryName(filename); Directory.CreateDirectory(dir); } zr = zipOut.ZipFileCreate(filename); if (zr != ZipReturn.ZipGood) { MessageBox.Show("Error creating " + Path.Combine(outDir, tGame.Name + ".zip") + " " + zr); return; } for (int rIndex = 0; rIndex < tGame.Roms.Count; rIndex++) { RvRom tRom = tGame.Roms[rIndex]; if (tRom.FileId != null) { GZip sourceGZip = new GZip(); string sha1 = Getfilename(GetFile.Execute((uint)tRom.FileId)); zr = sourceGZip.ReadGZip(sha1, false); if (zr != ZipReturn.ZipGood) { sourceGZip.Close(); continue; } Stream outStream; zipOut.ZipFileOpenWriteStream(true, true, tRom.Name, sourceGZip.uncompressedSize, 8, out outStream); Stream gZipStream; zr = sourceGZip.GetRawStream(out gZipStream); if (zr == ZipReturn.ZipGood) { // write the gzip stream to the zipstream ulong sizetogo = sourceGZip.compressedSize; while (sizetogo > 0) { int sizenow = sizetogo > BufferSize ? (int)BufferSize : (int)sizetogo; gZipStream.Read(buffer, 0, sizenow); outStream.Write(buffer, 0, sizenow); sizetogo = sizetogo - (ulong)sizenow; } } sourceGZip.Close(); zipOut.ZipFileCloseWriteStream(sourceGZip.crc); } } zipOut.ZipFileClose(); }
public static List<RvGame> ReadGames(uint DatId, bool readRoms = false) { List<RvGame> games = new List<RvGame>(); SqlReadGames.Parameters["DatId"].Value = DatId; using (SQLiteDataReader dr = SqlReadGames.ExecuteReader()) { while (dr.Read()) { RvGame rvGame = new RvGame(); rvGame.ReadFromReader(dr, readRoms); games.Add(rvGame); } dr.Close(); } return games; }