private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc) { XmlNodeList head = doc.SelectNodes("softwarelist"); if (head == null) return false; if (head.Count == 0) return false; if (head[0].Attributes == null) return false; RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(head[0].Attributes.GetNamedItem("name"))); tDat.AddData(RvDat.DatData.Description, VarFix.String(head[0].Attributes.GetNamedItem("description"))); string val = VarFix.String(head[0].Attributes.GetNamedItem("forcemerging")).ToLower(); switch (val.ToLower()) { case "split": tDat.AddData(RvDat.DatData.MergeType, "split"); break; case "full": tDat.AddData(RvDat.DatData.MergeType, "full"); break; default: tDat.AddData(RvDat.DatData.MergeType, "split"); break; } tDir.Dat = tDat; return true; }
public static bool ReadMameDat(ref RvDir tDat, XmlDocument doc) { FileType thisFileType = FileType.Unknown; if (!LoadMameHeaderFromDat(ref tDat, ref doc, ref thisFileType)) return false; if (doc.DocumentElement == null) return false; XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir"); if (dirNodeList != null) { for (int i = 0; i < dirNodeList.Count; i++) { LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType); } } XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game"); if (gameNodeList != null) { for (int i = 0; i < gameNodeList.Count; i++) { LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType); } } return true; }
public static bool ReadDat(ref RvDir tDat, XmlDocument doc) { FileType thisFileType = FileType.Unknown; if (!LoadHeaderFromDat(ref tDat, ref doc, ref thisFileType)) return false; if (doc.DocumentElement == null) return false; XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir"); if (dirNodeList != null) { foreach (XmlNode dirNode in dirNodeList) LoadDirFromDat(ref tDat, dirNode, thisFileType); } XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game"); if (gameNodeList != null) { foreach (XmlNode gameNode in gameNodeList) LoadGameFromDat(ref tDat, gameNode, thisFileType); } XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine"); if (machineNodeList != null) { foreach (XmlNode machineNode in machineNodeList) LoadGameFromDat(ref tDat, machineNode, thisFileType); } return true; }
private static void ProcessDir(RvDir dir, int depth = 1) { string d = new string(' ', 4 * depth); for (int i = 0; i < dir.ChildCount; i++) { RvDir game = dir.Child(i) as RvDir; if (game != null && game.FileType == FileType.Zip) { WriteLine(d + "<game name=\"" + clean(game.Name) + "\">"); WriteLine(d + " <description>" + clean(game.Name) + "</description>"); for (int j = 0; j < game.ChildCount; j++) { RvFile file = game.Child(j) as RvFile; if (file != null) { WriteLine(d + " <rom name=\"" + clean(file.Name) + "\" size=\"" + file.Size + "\" crc=\"" + Utils.ArrByte.ToString(file.CRC) + "\" md5=\"" + Utils.ArrByte.ToString(file.MD5) + "\" sha1=\"" + Utils.ArrByte.ToString(file.SHA1) + "\"/>"); } } WriteLine(d + "</game>"); } if (game != null && game.FileType == FileType.Dir) { WriteLine(d + "<dir name=\"" + clean(game.Name) + "\">"); ProcessDir(game, depth + 1); WriteLine(d + "</dir>"); } } }
private static void WriteDatFile(RvDir dir) { WriteLine("<?xml version=\"1.0\"?>"); WriteLine(""); WriteLine("<datafile>"); WriteHeader(); /* write Games/Dirs */ ProcessDir(dir); WriteLine("</datafile>"); }
private void SetupTree(RvDir pTree, string pTreeBranches) { int nodeDepth = pTreeBranches.Length - 1; pTree.Tree.TreeBranches = pTreeBranches; pTree.Tree.RTree = new Rectangle(0, _yPos - 8, 1 + nodeDepth * 18, 16); pTree.Tree.RExpand = new Rectangle(5 + nodeDepth * 18, _yPos + 4, 9, 9); pTree.Tree.RChecked = new Rectangle(20 + nodeDepth * 18, _yPos + 2, 13, 13); pTree.Tree.RIcon = new Rectangle(35 + nodeDepth * 18, _yPos, 16, 16); pTree.Tree.RText = new Rectangle(51 + nodeDepth * 18, _yPos, 500, 16); pTreeBranches = pTreeBranches.Replace("├", "│"); pTreeBranches = pTreeBranches.Replace("└", " "); _yPos = _yPos + 16; bool found = false; int last = 0; for (int i = 0; i < pTree.ChildCount; i++) { RvBase t = pTree.Child(i); if (t is RvDir) if (((RvDir)t).Tree != null) { found = true; if (pTree.Tree.TreeExpanded) last = i; } } if (!found) pTree.Tree.RExpand = new Rectangle(0, 0, 0, 0); for (int i = 0; i < pTree.ChildCount; i++) { RvBase t = pTree.Child(i); if (t is RvDir) if (((RvDir)t).Tree != null) { if (pTree.Tree.TreeExpanded) { if (i != last) SetupTree((RvDir)pTree.Child(i), pTreeBranches + "├"); else SetupTree((RvDir)pTree.Child(i), pTreeBranches + "└"); } } } }
public static void MakeDatFromDir(RvDir startingDir) { _datName = startingDir.Name; _datDir = startingDir.Name; Console.WriteLine("Creating Dat: " + startingDir.Name + ".dat"); _sw = new StreamWriter(startingDir.Name + ".dat"); WriteDatFile(startingDir); _sw.Close(); Console.WriteLine("Dat creation complete"); }
private static void GetSelectedDirList(ref List<RvDir> lstDir, RvDir thisDir) { for (int i = 0; i < thisDir.ChildCount; i++) { if (thisDir.DatStatus != DatStatus.InDatCollect) continue; RvDir tDir = thisDir.Child(i) as RvDir; if (tDir == null) continue; if (tDir.Tree == null) continue; if (tDir.Tree.Checked == RvTreeRow.TreeSelect.Selected) lstDir.Add(tDir); GetSelectedDirList(ref lstDir, tDir); } }
public static void Read(object sender, DoWorkEventArgs e) { Bgw = sender as BackgroundWorker; Program.SyncCont = e.Argument as SynchronizationContext; if (!File.Exists(Settings.CacheFile)) { OpenDefaultDB(); Bgw = null; Program.SyncCont = null; return; } DirTree = new RvDir(FileType.Dir); FileStream fs = new FileStream(Settings.CacheFile, FileMode.Open, FileAccess.Read); if (fs.Length < 4) ReportError.UnhandledExceptionHandler("Cache is Corrupt, revert to Backup."); BinaryReader br = new BinaryReader(fs); if (Bgw != null) Bgw.ReportProgress(0, new bgwSetRange((int)fs.Length)); DBVersion.VersionNow = br.ReadInt32(); if (DBVersion.VersionNow != DBVersion.Version) { ReportError.Show(Resources.DB_Read_Data_Cache_version_is_out_of_date_you_should_now_rescan_your_dat_directory_and_roms_directory_); OpenDefaultDB(); } else { DirTree.Read(br, null); } if (fs.Position > fs.Length - 8) ReportError.UnhandledExceptionHandler("Cache is Corrupt, revert to Backup."); ulong testEOF = br.ReadUInt64(); if (testEOF != EndCacheMarker) ReportError.UnhandledExceptionHandler("Cache is Corrupt, revert to Backup."); br.Close(); fs.Close(); fs.Dispose(); Bgw = null; Program.SyncCont = null; }
public static bool ReadDat(ref RvDir tDat, XmlDocument doc) { if (!LoadHeaderFromDat(ref tDat, ref doc)) return false; if (doc.DocumentElement == null) return false; XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("software"); if (gameNodeList == null) return false; for (int i = 0; i < gameNodeList.Count; i++) { LoadGameFromDat(ref tDat, gameNodeList[i]); } return true; }
private static void LoadDiskFromDat(ref RvDir tGame, XmlNode romNode) { if (romNode.Attributes == null) return; XmlNode name = romNode.Attributes.GetNamedItem("name"); RvFile tRom = new RvFile(FileType.File) { Name = VarFix.CleanFullFileName(name) + ".chd", SHA1CHD = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40), Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")), Dat = tGame.Dat }; if (tRom.SHA1CHD != null) tRom.FileStatusSet(FileStatus.SHA1CHDFromDAT); tGame.ChildAdd(tRom); }
private static bool LoadHeaderFromDat(ref RvDir tDir, ref FileType thisFileType) { if (DatFileLoader.Next != "(") { DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadHeaderFromDat_not_found_after_clrmamepro, DatFileLoader.Filename); return false; } DatFileLoader.Gn(); RvDat tDat = new RvDat(); while (DatFileLoader.Next != ")") { string nextstr = DatFileLoader.Next.ToLower(); if (nextstr.Length > 5 && nextstr.Substring(0, 5) == "name:") { tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(DatFileLoader.Next.Substring(5) + " " + DatFileLoader.GnRest()).Trim()); DatFileLoader.Gn(); } else { switch (nextstr) { case "name:": tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(DatFileLoader.GnRest())); DatFileLoader.Gn(); break; case "description:": tDat.AddData(RvDat.DatData.Description , DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "version:": tDat.AddData(RvDat.DatData.Version , DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "date:": tDat.AddData(RvDat.DatData.Date , DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "author:": tDat.AddData(RvDat.DatData.Author , DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "homepage:": tDat.AddData(RvDat.DatData.HomePage , DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "comment:": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadHeaderFromDat_not_known_in_clrmamepro, DatFileLoader.Filename); DatFileLoader.Gn(); break; } } } thisFileType = FileType.ZipFile; tDir.Dat = tDat; return true; }
public void SetSelected(RvDir selected) { bool found = false; RvDir t = selected; while (t != null) { if (t.Tree != null) { if (!found) { _lSelected = t; found = true; } else t.Tree.TreeExpanded = true; } t = t.Parent; } SetupInt(); }
public static bool ReadDat(ref RvDir tDat, string strFilename) { RvDir tNow = tDat; FileType thisFileType = FileType.Unknown; int errorCode = DatFileLoader.LoadDat(strFilename); if (errorCode != 0) { DatUpdate.ShowDat(new Win32Exception(errorCode).Message, strFilename); return false; } DatFileLoader.Gn(); while (!DatFileLoader.EndOfStream()) { switch (DatFileLoader.Next.ToLower()) { case "doscenter": _cleanFileNames = true; DatFileLoader.Gn(); if (!LoadHeaderFromDat(ref tNow, ref thisFileType)) return false; DatFileLoader.Gn(); break; case "game": DatFileLoader.Gn(); if (!LoadGameFromDat(ref tNow, thisFileType)) return false; DatFileLoader.Gn(); break; default: DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_ReadDat_not_known, DatFileLoader.Filename); DatFileLoader.Gn(); break; } } DatFileLoader.Close(); return true; }
private static void OpenDefaultDB() { DirTree = new RvDir(FileType.Dir) { Tree = new RvTreeRow(), DatStatus = DatStatus.InDatCollect }; RvDir rv = new RvDir(FileType.Dir) { Name = "RomVault", Tree = new RvTreeRow(), DatStatus = DatStatus.InDatCollect }; DirTree.ChildAdd(rv); RvDir ts = new RvDir(FileType.Dir) { Name = "ToSort", Tree = new RvTreeRow(), DatStatus = DatStatus.InDatCollect }; DirTree.ChildAdd(ts); }
private static bool IsDeepScanned(RvDir tZip) { for (int i = 0; i < tZip.ChildCount; i++) { RvFile zFile = tZip.Child(i) as RvFile; if (zFile != null && zFile.GotStatus == GotStatus.Got && (!zFile.FileStatusIs(FileStatus.SizeVerified) || !zFile.FileStatusIs(FileStatus.CRCVerified) || !zFile.FileStatusIs(FileStatus.SHA1Verified) || !zFile.FileStatusIs(FileStatus.MD5Verified))) return false; } return true; }
private static void DBFileNotFound(RvBase dbChild, RvDir dbDir, ref int dbIndex) { if (dbChild == null) { ReportError.SendAndShow(Resources.FileScanning_CheckADir_Error_in_File_Scanning_Code); return; } if (dbChild.FileRemove() == EFile.Delete) dbDir.ChildRemove(dbIndex); else { switch (dbChild.FileType) { case FileType.Zip: MarkAsMissing((RvDir)dbChild); break; case FileType.Dir: RvDir tDir = (RvDir)dbChild; if (tDir.Tree == null) MarkAsMissing(tDir); break; } dbIndex++; } }
private static void NewFileFound(RvBase fileChild, RvDir dbDir, int dbIndex) { if (fileChild == null) { ReportError.SendAndShow(Resources.FileScanning_CheckADir_Error_in_File_Scanning_Code); return; } // this could be an unknown file, or dirctory. // if item is a directory add the directory and call back in again // add the newly found item switch (fileChild.FileType) { case FileType.Zip: dbDir.ChildAdd(fileChild, dbIndex); CheckADir((RvDir)fileChild, false); break; case FileType.Dir: dbDir.ChildAdd(fileChild, dbIndex); CheckADir((RvDir)fileChild, true); break; case FileType.File: RvFile tChild = (RvFile)fileChild; // if we have not read the files CRC in the checking code, we need to read it now. if (tChild.GotStatus != GotStatus.FileLocked) { if (!IsDeepScanned(tChild)) DeepScanFile(dbDir.FullName, tChild); if (!IschdmanScanned(tChild) && EScanLevel == eScanLevel.Level2) ChdManCheck(dbDir.FullName, tChild); } dbDir.ChildAdd(fileChild, dbIndex); break; case FileType.ZipFile: dbDir.ChildAdd(fileChild, dbIndex); break; default: throw new Exception("Unsuported file type " + fileChild.FileType); } }
public static void Compare(RvDir dbDir, RvDir fileDir, bool report, bool enableCancel) { string fullDir = dbDir.FullName; FileType ft = dbDir.FileType; // now we scan down the dbDir and the scanDir, comparing them. // if we find a match we mark dbDir as found. // if we are missing a file in scanDir we mark that file in dbDir as missing. // if we find extra files in scanDir we add it to dbDir and mark it as unknown. // we also recurse into any sub directories. int dbIndex = 0; int fileIndex = 0; while (dbIndex < dbDir.ChildCount || fileIndex < fileDir.ChildCount) { RvBase dbChild = null; RvBase fileChild = null; int res = 0; if (dbIndex < dbDir.ChildCount && fileIndex < fileDir.ChildCount) { dbChild = dbDir.Child(dbIndex); fileChild = fileDir.Child(fileIndex); res = DBHelper.CompareName(dbChild, fileChild); } else if (fileIndex < fileDir.ChildCount) { //Get any remaining filedir's fileChild = fileDir.Child(fileIndex); res = 1; } else if (dbIndex < dbDir.ChildCount) { //Get any remaining dbDir's dbChild = dbDir.Child(dbIndex); res = -1; } if (report) { if (fileChild != null) { long timenow = DateTime.Now.Ticks; if ((timenow - _lastUpdateTime) > (TimeSpan.TicksPerSecond / 10)) { _lastUpdateTime = timenow; _bgw.ReportProgress(0, new bgwValue2(fileIndex)); _bgw.ReportProgress(0, new bgwText2(Path.Combine(fullDir, fileChild.Name))); } } } // if this file was found in the DB switch (res) { case 0: if (dbChild == null || fileChild == null) { ReportError.SendAndShow(Resources.FileScanning_CheckADir_Error_in_File_Scanning_Code); break; } //Complete MultiName Compare List<RvBase> dbs = new List<RvBase>(); List<RvBase> files = new List<RvBase>(); int dbsCount = 1; int filesCount = 1; dbs.Add(dbChild); files.Add(fileChild); while (dbIndex + dbsCount < dbDir.ChildCount && DBHelper.CompareName(dbChild, dbDir.Child(dbIndex + dbsCount)) == 0) { dbs.Add(dbDir.Child(dbIndex + dbsCount)); dbsCount += 1; } while (fileIndex + filesCount < fileDir.ChildCount && DBHelper.CompareName(fileChild, fileDir.Child(fileIndex + filesCount)) == 0) { files.Add(fileDir.Child(fileIndex + filesCount)); filesCount += 1; } for (int indexfile = 0; indexfile < filesCount; indexfile++) { if (files[indexfile].SearchFound) continue; for (int indexdb = 0; indexdb < dbsCount; indexdb++) { if (dbs[indexdb].SearchFound) continue; bool matched = FullCompare(dbs[indexdb], files[indexfile], false, fullDir, EScanLevel); if (!matched) continue; MatchFound(dbs[indexdb], files[indexfile]); dbs[indexdb].SearchFound = true; files[indexfile].SearchFound = true; } if (files[indexfile].SearchFound) continue; for (int indexdb = 0; indexdb < dbsCount; indexdb++) { if (dbs[indexdb].SearchFound) continue; bool matched = FullCompare(dbs[indexdb], files[indexfile], true, fullDir, EScanLevel); if (!matched) continue; MatchFound(dbs[indexdb], files[indexfile]); dbs[indexdb].SearchFound = true; files[indexfile].SearchFound = true; } } for (int indexdb = 0; indexdb < dbsCount; indexdb++) { if (dbs[indexdb].SearchFound) { dbIndex++; continue; } DBFileNotFound(dbs[indexdb], dbDir, ref dbIndex); } for (int indexfile = 0; indexfile < filesCount; indexfile++) { if (files[indexfile].SearchFound) continue; NewFileFound(files[indexfile], dbDir, dbIndex); dbIndex++; } fileIndex += filesCount; break; case 1: NewFileFound(fileChild, dbDir, dbIndex); dbIndex++; fileIndex++; break; case -1: DBFileNotFound(dbChild, dbDir, ref dbIndex); break; } if (_fileErrorAbort) return; if (enableCancel && !DBTypeGet.isCompressedDir(ft) && _bgw.CancellationPending) return; } }
private static void CheckADir(RvDir dbDir, bool report) { if (_cacheSaveTimer.Elapsed.TotalMinutes > Settings.CacheSaveTimePeriod) { _bgw.ReportProgress(0, "Saving Cache"); DB.Write(); _bgw.ReportProgress(0, "Saving Cache Complete"); _cacheSaveTimer.Reset(); _cacheSaveTimer.Start(); } string fullDir = dbDir.FullName; if (report) _bgw.ReportProgress(0, new bgwText2(fullDir)); DatStatus chechingDatStatus = dbDir.IsInToSort ? DatStatus.InToSort : DatStatus.NotInDat; // this is a temporary rvDir structure to store the data about the actual directory/files we are scanning // we will first populate this variable with the real file data from the directory, and then compare it // with the data in dbDir. RvDir fileDir = null; Debug.WriteLine(fullDir); FileType ft = dbDir.FileType; #region "Populate fileDir" // if we are scanning a ZIP file then populate scanDir from the ZIP file switch (ft) { case FileType.Zip: { fileDir = new RvDir(ft); // open the zip file ZipFile checkZ = new ZipFile(); ZipReturn zr = checkZ.ZipFileOpen(fullDir, dbDir.TimeStamp, true); if (zr == ZipReturn.ZipGood) { dbDir.ZipStatus = checkZ.ZipStatus; // to be Scanning a ZIP file means it is either new or has changed. // as the code below only calls back here if that is true. // // Level1: Only use header CRC's // Just get the CRC for the ZIP headers. // // Level2: Fully checksum changed only files // We know this file has been changed to do a full checksum scan. // // Level3: Fully checksum everything // So do a full checksum scan. if (EScanLevel == eScanLevel.Level2 || EScanLevel == eScanLevel.Level3) checkZ.DeepScan(); // add all of the file information from the zip file into scanDir for (int i = 0; i < checkZ.LocalFilesCount(); i++) { RvFile tFile = new RvFile(DBTypeGet.FileFromDir(ft)) { Name = checkZ.Filename(i), ZipFileIndex = i, ZipFileHeaderPosition = checkZ.LocalHeader(i), Size = checkZ.UncompressedSize(i), CRC = checkZ.CRC32(i) }; // all 3 levels read the CRC from the ZIP header tFile.SetStatus(chechingDatStatus, GotStatus.Got); tFile.FileStatusSet(FileStatus.SizeFromHeader | FileStatus.CRCFromHeader); // if we are in level 2 or level 3 then do a full CheckSum Scan. if (EScanLevel == eScanLevel.Level2 || EScanLevel == eScanLevel.Level3) { // DeepScan will return ZipReturn.ZipCRCDecodeError if the headers CRC and // the actual CRC do not match. // So we just need to set the MD5 and SHA1 from the ZIP file. zr = checkZ.FileStatus(i); if (zr == ZipReturn.ZipUntested) { _bgw.ReportProgress(0, new bgwShowCorrupt(zr, fullDir + " : " + checkZ.Filename(i))); } else if (zr != ZipReturn.ZipGood) { _bgw.ReportProgress(0, new bgwShowCorrupt(zr, fullDir + " : " + checkZ.Filename(i))); tFile.GotStatus = GotStatus.Corrupt; } else { tFile.MD5 = checkZ.MD5(i); tFile.SHA1 = checkZ.SHA1(i); tFile.FileStatusSet(FileStatus.SizeVerified | FileStatus.CRCVerified | FileStatus.SHA1Verified | FileStatus.MD5Verified); } } fileDir.ChildAdd(tFile); } } else if (zr == ZipReturn.ZipFileLocked) { _bgw.ReportProgress(0, new bgwShowError(fullDir, "Zip File Locked")); dbDir.TimeStamp = 0; dbDir.GotStatus = GotStatus.FileLocked; } else { _bgw.ReportProgress(0, new bgwShowCorrupt(zr, fullDir)); dbDir.GotStatus = GotStatus.Corrupt; } checkZ.ZipFileClose(); } break; case FileType.Dir: { fileDir = new RvDir(FileType.Dir); DirectoryInfo oDir = new DirectoryInfo(fullDir); DirectoryInfo[] oDirs = oDir.GetDirectories(); FileInfo[] oFiles = oDir.GetFiles(); // add all the subdirectories into scanDir foreach (DirectoryInfo dir in oDirs) { RvBase tDir = new RvDir(FileType.Dir) { Name = dir.Name, TimeStamp = dir.LastWriteTime, }; tDir.SetStatus(chechingDatStatus, GotStatus.Got); fileDir.ChildAdd(tDir); } // add all the files into scanDir foreach (FileInfo oFile in oFiles) { // if we find any zip files add them as zip files. string fExt = Path.GetExtension(oFile.Name); switch (fExt.ToLower()) { case ".zip": { RvDir tGame = new RvDir(FileType.Zip) { Name = Path.GetFileNameWithoutExtension(oFile.Name), TimeStamp = oFile.LastWriteTime, }; tGame.SetStatus(chechingDatStatus, GotStatus.Got); fileDir.ChildAdd(tGame); } break; default: { string fName = oFile.Name; if (fName == "__RomVault.tmp") { File.Delete(oFile.FullName); continue; } // Scanning a file // // Level1 & 2 : (are the same for files) Fully checksum changed only files // Here we are just getting the TimeStamp of the File, and later // if the TimeStamp was not matched we will have to read the files CRC, MD5 & SHA1 // // Level3: Fully checksum everything // Get everything about the file right here so // read CRC, MD5 & SHA1 // add all the files in the sub-directory to scanDir RvFile tFile = new RvFile(FileType.File) { Name = fName, Size = (ulong)oFile.Length, TimeStamp = oFile.LastWriteTime }; tFile.FileStatusSet(FileStatus.SizeVerified); int errorCode = CHD.CheckFile(oFile, out tFile.SHA1CHD, out tFile.MD5CHD, out tFile.CHDVersion); if (errorCode == 0) { if (tFile.SHA1CHD != null) tFile.FileStatusSet(FileStatus.SHA1CHDFromHeader); if (tFile.MD5CHD != null) tFile.FileStatusSet(FileStatus.MD5CHDFromHeader); tFile.SetStatus(chechingDatStatus, GotStatus.Got); // if we are scanning at Level3 then we get all the info here if (EScanLevel == eScanLevel.Level3) { DeepScanFile(fullDir, tFile); ChdManCheck(fullDir, tFile); } } else if (errorCode == 32) { tFile.GotStatus = GotStatus.FileLocked; _bgw.ReportProgress(0, new bgwShowError(fullDir, "File Locked")); } else { string filename = Path.Combine(fullDir, tFile.Name); ReportError.Show("File: " + filename + " Error: " + new Win32Exception(errorCode).Message + ". Scan Aborted."); _fileErrorAbort = true; return; } fileDir.ChildAdd(tFile); } break; } } } break; default: ReportError.SendAndShow("Un supported file type in CheckADir " + ft); break; } #endregion if (fileDir == null) { ReportError.SendAndShow("Unknown Reading File Type in Dir Scanner"); return; } if (report) { _bgw.ReportProgress(0, new bgwSetRange2(fileDir.ChildCount - 1)); _bgw.ReportProgress(0, new bgwRange2Visible(true)); } if (!DBTypeGet.isCompressedDir(ft) && _bgw.CancellationPending) return; Compare(dbDir, fileDir, report, true); }
/* autodetect A2601 code ported from Stella */ public string autodetectA2601(RvDir tGame) { string CWD = string.Concat(Application.StartupPath, Path.DirectorySeparatorChar + "papilio" + Path.DirectorySeparatorChar +"_tmp" + Path.DirectorySeparatorChar); string cartrom = RomGrid.Rows[0].Cells["CRom"].Value.ToString(); if (System.IO.File.Exists(string.Concat(CWD,cartrom))) { string[] cartrom_size = RomGrid.Rows[0].Cells["CSize"].Value.ToString().Trim().Split(' '); //MessageBox.Show(cartrom_size[0].ToString()); int rom_size = Convert.ToInt32(cartrom_size[0]); string cartrom_data = BitConverter.ToString(File.ReadAllBytes(string.Concat(CWD, cartrom))); // missing a ton of bank types.. if (rom_size <= 2048) { return "2K"; } if (rom_size <= 4096) { return "4K"; } if (rom_size <= 8 * 1024) { bool F8 = isProbablyF8(cartrom_data); if (isProbablySC(cartrom_data)) return "F8-SC"; if (isProbablyE0(cartrom_data)) return "E0"; if (isProbably3F(cartrom_data)) return "3F"; if (isProbablyFE(cartrom_data) && !F8) return "FE"; //if (isProbablyF8(cartrom_data)) return "F8"; } if (rom_size <= 16 * 1024) { if (isProbablySC(cartrom_data)) return "F6-SC"; //if (isProbablyF6(cartrom_data)) return "F6"; } if (rom_size <= 32 * 1024) { //if (isProbably3F(cartrom_data)) return "3F"; } if (rom_size <= 64 * 1024) { //if (isProbably3F(cartrom_data)) return "3F"; } if (rom_size <= 128 * 1024) { //if (isProbably3F(cartrom_data)) return "3F"; } if (rom_size <= 256 * 1024) { //if (isProbably3F(cartrom_data)) return "3F"; } if (isProbably3F(cartrom_data)) return "3F"; doLog(" - - Unsupported BSS Type. Trying No BSS (4K) method"); return "4K"; } else { doLog(string.Concat(" - - Aborting - `",cartrom,"` not found")); return "-1"; } //return "-1"; }
private void AddDir(RvDir tGame, string pathAdd) { for (int l = 0; l < tGame.ChildCount; l++) { RvBase tBase = tGame.Child(l); RvFile tFile = tBase as RvFile; if (tFile != null) AddRom((RvFile)tBase, pathAdd); if (tGame.Dat == null) continue; RvDir tDir = tBase as RvDir; if (tDir == null) continue; if (tDir.Game == null) AddDir(tDir, pathAdd + tGame.Name + "/"); } }
private void UpdateRomGrid(RvDir tGame) { lblSITName.Text = tGame.Name; if (tGame.Game == null) { 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; } else { if (tGame.Game.GetData(RvGame.GameData.Trurip) == "yes") { lblSIDescription.Visible = true; lblSITDescription.Visible = true; lblSITDescription.Text = tGame.Game.GetData(RvGame.GameData.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.Game.GetData(RvGame.GameData.Publisher); lblSIDeveloper.Visible = true; lblSITDeveloper.Visible = true; lblSITDeveloper.Text = tGame.Game.GetData(RvGame.GameData.Developer); lblSIEdition.Visible = true; lblSITEdition.Visible = true; lblSITEdition.Text = tGame.Game.GetData(RvGame.GameData.Edition); lblSIVersion.Visible = true; lblSITVersion.Visible = true; lblSITVersion.Text = tGame.Game.GetData(RvGame.GameData.Version); lblSIType.Visible = true; lblSITType.Visible = true; lblSITType.Text = tGame.Game.GetData(RvGame.GameData.Type); lblSIMedia.Visible = true; lblSITMedia.Visible = true; lblSITMedia.Text = tGame.Game.GetData(RvGame.GameData.Media); lblSILanguage.Visible = true; lblSITLanguage.Visible = true; lblSITLanguage.Text = tGame.Game.GetData(RvGame.GameData.Language); lblSIPlayers.Visible = true; lblSITPlayers.Visible = true; lblSITPlayers.Text = tGame.Game.GetData(RvGame.GameData.Players); lblSIRatings.Visible = true; lblSITRatings.Visible = true; lblSITRatings.Text = tGame.Game.GetData(RvGame.GameData.Ratings); lblSIGenre.Visible = true; lblSITGenre.Visible = true; lblSITGenre.Text = tGame.Game.GetData(RvGame.GameData.Genre); lblSIPeripheral.Visible = true; lblSITPeripheral.Visible = true; lblSITPeripheral.Text = tGame.Game.GetData(RvGame.GameData.Peripheral); lblSIBarCode.Visible = true; lblSITBarCode.Visible = true; lblSITBarCode.Text = tGame.Game.GetData(RvGame.GameData.BarCode); lblSIMediaCatalogNumber.Visible = true; lblSITMediaCatalogNumber.Visible = true; lblSITMediaCatalogNumber.Text = tGame.Game.GetData(RvGame.GameData.MediaCatalogNumber); } else { lblSIDescription.Visible = true; lblSITDescription.Visible = true; lblSITDescription.Text = tGame.Game.GetData(RvGame.GameData.Description); lblSIManufacturer.Visible = true; lblSITManufacturer.Visible = true; lblSITManufacturer.Text = tGame.Game.GetData(RvGame.GameData.Manufacturer); lblSICloneOf.Visible = true; lblSITCloneOf.Visible = true; lblSITCloneOf.Text = tGame.Game.GetData(RvGame.GameData.CloneOf); lblSIRomOf.Visible = true; lblSITRomOf.Visible = true; lblSITRomOf.Text = tGame.Game.GetData(RvGame.GameData.RomOf); lblSIYear.Visible = true; lblSITYear.Visible = true; lblSITYear.Text = tGame.Game.GetData(RvGame.GameData.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; } } if (Settings.IsMono && RomGrid.RowCount > 0) RomGrid.CurrentCell = RomGrid[0,0]; RomGrid.Rows.Clear(); AddDir(tGame, ""); GC.Collect(); }
private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc, ref FileType thisFileType) { if (doc.DocumentElement == null) return false; XmlNode head = doc.DocumentElement.SelectSingleNode("header"); if (head == null) return false; RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(head.SelectSingleNode("name"))); tDat.AddData(RvDat.DatData.RootDir, VarFix.CleanFileName(head.SelectSingleNode("rootdir"))); tDat.AddData(RvDat.DatData.Description, VarFix.String(head.SelectSingleNode("description"))); tDat.AddData(RvDat.DatData.Category, VarFix.String(head.SelectSingleNode("category"))); tDat.AddData(RvDat.DatData.Version, VarFix.String(head.SelectSingleNode("version"))); tDat.AddData(RvDat.DatData.Date, VarFix.String(head.SelectSingleNode("date"))); tDat.AddData(RvDat.DatData.Author, VarFix.String(head.SelectSingleNode("author"))); tDat.AddData(RvDat.DatData.Email, VarFix.String(head.SelectSingleNode("email"))); tDat.AddData(RvDat.DatData.HomePage, VarFix.String(head.SelectSingleNode("homepage"))); tDat.AddData(RvDat.DatData.URL, VarFix.String(head.SelectSingleNode("url"))); string superDAT = VarFix.String(head.SelectSingleNode("type")); _cleanFileNames = superDAT.ToLower() != "superdat" && superDAT.ToLower() != "gigadat"; if (!_cleanFileNames) tDat.AddData(RvDat.DatData.SuperDat, "superdat"); thisFileType = FileType.ZipFile; // Look for: <romvault forcepacking="unzip"/> XmlNode packingNode = head.SelectSingleNode("romvault"); if (packingNode == null) // Look for: <clrmamepro forcepacking="unzip"/> packingNode = head.SelectSingleNode("clrmamepro"); if (packingNode != null) { if (packingNode.Attributes != null) { string val = VarFix.String(packingNode.Attributes.GetNamedItem("forcepacking")).ToLower(); switch (val.ToLower()) { case "zip": tDat.AddData(RvDat.DatData.FileType, "zip"); thisFileType = FileType.ZipFile; break; case "unzip": case "file": tDat.AddData(RvDat.DatData.FileType, "file"); thisFileType = FileType.File; break; default: thisFileType = FileType.ZipFile; break; } val = VarFix.String(packingNode.Attributes.GetNamedItem("forcemerging")).ToLower(); switch (val.ToLower()) { case "split": tDat.AddData(RvDat.DatData.MergeType, "split"); break; case "full": tDat.AddData(RvDat.DatData.MergeType, "full"); break; default: tDat.AddData(RvDat.DatData.MergeType, "split"); break; } val = VarFix.String(packingNode.Attributes.GetNamedItem("dir")).ToLower(); // noautodir , nogame if (!String.IsNullOrEmpty(val)) tDat.AddData(RvDat.DatData.DirSetup, val); } } // Look for: <notzipped>true</notzipped> string notzipped = VarFix.String(head.SelectSingleNode("notzipped")); if (notzipped.ToLower() == "true" || notzipped.ToLower() == "yes") thisFileType = FileType.File; tDir.Dat = tDat; return true; }
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 static void LoadGameFromDat(ref RvDir tDat, XmlNode gameNode, FileType thisFileType) { if (gameNode.Attributes == null) return; RvDir parent = tDat; RvDir tDir; int index1 = 0; string fullname = VarFix.CleanFullFileName(gameNode.Attributes.GetNamedItem("name")); if (_cleanFileNames) fullname = fullname.Replace("/", "-"); else { while (fullname.Contains("/")) { int firstSlash = fullname.IndexOf("/", StringComparison.Ordinal); string dir = fullname.Substring(0, firstSlash); dir = VarFix.CleanFileName(dir); fullname = fullname.Substring(firstSlash + 1); int index; if (parent.ChildNameSearch(new RvDir(FileType.Dir) { Name = dir }, out index) == 0) { parent = (RvDir)parent.Child(index); } else { RvDir tpDir = new RvDir(FileType.Dir) { Name = dir, DatStatus = DatStatus.InDatCollect, Dat = tDat.Dat, Tree = new RvTreeRow() }; parent.ChildAdd(tpDir, index); parent = tpDir; } } } tDir = new RvDir(DBTypeGet.DirFromFile(thisFileType)) { Name = fullname, DatStatus = DatStatus.InDatCollect, Dat = tDat.Dat }; string testName = tDir.Name; int nameCount = 0; while (parent.ChildNameSearch(tDir, out index1) == 0) { tDir.Name = testName + "_" + nameCount; nameCount++; } tDir.Game = new RvGame(); tDir.Game.AddData(RvGame.GameData.RomOf, VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("romof"))); tDir.Game.AddData(RvGame.GameData.Description, VarFix.String(gameNode.SelectSingleNode("description"))); tDir.Game.AddData(RvGame.GameData.Sourcefile, VarFix.String(gameNode.Attributes.GetNamedItem("sourcefile"))); tDir.Game.AddData(RvGame.GameData.IsBios, VarFix.String(gameNode.Attributes.GetNamedItem("isbios"))); tDir.Game.AddData(RvGame.GameData.CloneOf, VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("cloneof"))); tDir.Game.AddData(RvGame.GameData.SampleOf, VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("sampleof"))); tDir.Game.AddData(RvGame.GameData.Board, VarFix.String(gameNode.Attributes.GetNamedItem("board"))); tDir.Game.AddData(RvGame.GameData.Year, VarFix.String(gameNode.SelectSingleNode("year"))); tDir.Game.AddData(RvGame.GameData.Manufacturer, VarFix.String(gameNode.SelectSingleNode("manufacturer"))); XmlNode trurip = gameNode.SelectSingleNode("trurip"); if (trurip != null) { tDir.Game.AddData(RvGame.GameData.Trurip, "yes"); tDir.Game.AddData(RvGame.GameData.Year, VarFix.String(trurip.SelectSingleNode("year"))); tDir.Game.AddData(RvGame.GameData.Publisher, VarFix.String(trurip.SelectSingleNode("publisher"))); tDir.Game.AddData(RvGame.GameData.Developer, VarFix.String(trurip.SelectSingleNode("developer"))); tDir.Game.AddData(RvGame.GameData.Edition, VarFix.String(trurip.SelectSingleNode("edition"))); tDir.Game.AddData(RvGame.GameData.Version, VarFix.String(trurip.SelectSingleNode("version"))); tDir.Game.AddData(RvGame.GameData.Type, VarFix.String(trurip.SelectSingleNode("type"))); tDir.Game.AddData(RvGame.GameData.Media, VarFix.String(trurip.SelectSingleNode("media"))); tDir.Game.AddData(RvGame.GameData.Language, VarFix.String(trurip.SelectSingleNode("language"))); tDir.Game.AddData(RvGame.GameData.Players, VarFix.String(trurip.SelectSingleNode("players"))); tDir.Game.AddData(RvGame.GameData.Ratings, VarFix.String(trurip.SelectSingleNode("ratings"))); tDir.Game.AddData(RvGame.GameData.Peripheral, VarFix.String(trurip.SelectSingleNode("peripheral"))); tDir.Game.AddData(RvGame.GameData.Genre, VarFix.String(trurip.SelectSingleNode("genre"))); tDir.Game.AddData(RvGame.GameData.MediaCatalogNumber, VarFix.String(trurip.SelectSingleNode("mediacatalognumber"))); tDir.Game.AddData(RvGame.GameData.BarCode, VarFix.String(trurip.SelectSingleNode("barcode"))); } RvDir tDirCHD = new RvDir(FileType.Dir) { Name = tDir.Name, DatStatus = tDir.DatStatus, Dat = tDir.Dat, Game = tDir.Game }; XmlNodeList romNodeList = gameNode.SelectNodes("rom"); if (romNodeList != null) for (int i = 0; i < romNodeList.Count; i++) LoadRomFromDat(ref tDir, romNodeList[i], thisFileType); XmlNodeList diskNodeList = gameNode.SelectNodes("disk"); if (diskNodeList != null) for (int i = 0; i < diskNodeList.Count; i++) LoadDiskFromDat(ref tDirCHD, diskNodeList[i]); if (tDir.ChildCount > 0) parent.ChildAdd(tDir, index1); if (tDirCHD.ChildCount > 0) parent.ChildAdd(tDirCHD); }
private static bool LoadMameHeaderFromDat(ref RvDir tDir, ref XmlDocument doc, ref FileType thisFileType) { if (doc.DocumentElement == null) return false; XmlNode head = doc.SelectSingleNode("mame"); if (head == null || head.Attributes == null) return false; RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatName, VarFix.CleanFileName(head.Attributes.GetNamedItem("build"))); tDat.AddData(RvDat.DatData.Description, VarFix.String(head.Attributes.GetNamedItem("build"))); thisFileType = FileType.ZipFile; tDir.Dat = tDat; return true; }
private static void MarkAsMissing(RvDir dbDir) { for (int i = 0; i < dbDir.ChildCount; i++) { RvBase dbChild = dbDir.Child(i); if (dbChild.FileRemove() == EFile.Delete) { dbDir.ChildRemove(i); i--; } else { switch (dbChild.FileType) { case FileType.Zip: MarkAsMissing((RvDir)dbChild); break; case FileType.Dir: RvDir tDir = (RvDir)dbChild; if (tDir.Tree == null) MarkAsMissing(tDir); break; } } } }
private static void LoadDirFromDat(ref RvDir tDat, XmlNode dirNode, FileType thisFileType) { if (dirNode.Attributes == null) return; RvDir parent = tDat; string fullname = VarFix.CleanFullFileName(dirNode.Attributes.GetNamedItem("name")); while (fullname.Contains("/")) { int firstSlash = fullname.IndexOf("/", StringComparison.Ordinal); string dir = fullname.Substring(0, firstSlash); dir = VarFix.CleanFileName(dir); fullname = fullname.Substring(firstSlash + 1); int index; if (parent.ChildNameSearch(new RvDir(FileType.Dir) { Name = dir }, out index) == 0) { parent = (RvDir)parent.Child(index); } else { RvDir tpDir = new RvDir(FileType.Dir) { Name = dir, DatStatus = DatStatus.InDatCollect, Dat = tDat.Dat, Tree = new RvTreeRow() }; parent.ChildAdd(tpDir, index); parent = tpDir; } } RvDir tDir = new RvDir(FileType.Dir) { Name = fullname, DatStatus = DatStatus.InDatCollect, Dat = tDat.Dat, Tree = new RvTreeRow() }; int index1; if (parent.ChildNameSearch(tDir, out index1) == 0) tDir = (RvDir)parent.Child(index1); else tDat.ChildAdd(tDir, index1); XmlNodeList dirNodeList = dirNode.SelectNodes("dir"); if (dirNodeList != null) { for (int i = 0; i < dirNodeList.Count; i++) { LoadDirFromDat(ref tDir, dirNodeList[i], thisFileType); } } XmlNodeList gameNodeList = dirNode.SelectNodes("game"); if (gameNodeList != null) { for (int i = 0; i < gameNodeList.Count; i++) { LoadGameFromDat(ref tDir, gameNodeList[i], thisFileType); } } }
private void UpdateGameGrid(RvDir tDir) { lblDITName.Text = tDir.Name; if (tDir.Dat != null) { RvDat tDat = tDir.Dat; lblDITDescription.Text = tDat.GetData(RvDat.DatData.Description); lblDITCategory.Text = tDat.GetData(RvDat.DatData.Category); lblDITVersion.Text = tDat.GetData(RvDat.DatData.Version); lblDITAuthor.Text = tDat.GetData(RvDat.DatData.Author); lblDITDate.Text = tDat.GetData(RvDat.DatData.Date); } else if (tDir.DirDatCount == 1) { RvDat tDat = tDir.DirDat(0); lblDITDescription.Text = tDat.GetData(RvDat.DatData.Description); lblDITCategory.Text = tDat.GetData(RvDat.DatData.Category); lblDITVersion.Text = tDat.GetData(RvDat.DatData.Version); lblDITAuthor.Text = tDat.GetData(RvDat.DatData.Author); lblDITDate.Text = tDat.GetData(RvDat.DatData.Date); } else { lblDITDescription.Text = ""; lblDITCategory.Text = ""; lblDITVersion.Text = ""; lblDITAuthor.Text = ""; lblDITDate.Text = ""; } lblDITPath.Text = tDir.FullName; lblDITRomsGot.Text = tDir.DirStatus.CountCorrect().ToString(CultureInfo.InvariantCulture); lblDITRomsMissing.Text = tDir.DirStatus.CountMissing().ToString(CultureInfo.InvariantCulture); lblDITRomsFixable.Text = tDir.DirStatus.CountFixesNeeded().ToString(CultureInfo.InvariantCulture); lblDITRomsUnknown.Text = (tDir.DirStatus.CountUnknown() + tDir.DirStatus.CountInToSort()).ToString(CultureInfo.InvariantCulture); _updatingGameGrid = true; if (Settings.IsMono) { if (GameGrid.RowCount > 0) GameGrid.CurrentCell = GameGrid[0,0]; if (RomGrid.RowCount > 0) RomGrid.CurrentCell = RomGrid[0,0]; } GameGrid.Rows.Clear(); RomGrid.Rows.Clear(); // clear sorting GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; _gameGridSortColumnIndex = 0; _gameGridSortOrder = SortOrder.Descending; ReportStatus tDirStat; _gameGridColumnXPositions = new int[(int)RepStatus.EndValue]; int rowCount = 0; for (int j = 0; j < tDir.ChildCount; j++) { RvDir tChildDir = tDir.Child(j) as RvDir; if (tChildDir == null) continue; tDirStat = tChildDir.DirStatus; bool gCorrect = tDirStat.HasCorrect(); bool gMissing = tDirStat.HasMissing(); bool gUnknown = tDirStat.HasUnknown(); bool gInToSort = tDirStat.HasInToSort(); bool gFixes = tDirStat.HasFixesNeeded(); bool show = (chkBoxShowCorrect.Checked && gCorrect && !gMissing && !gFixes); show = show || (chkBoxShowMissing.Checked && gMissing); show = show || (chkBoxShowFixed.Checked && gFixes); show = show || (gUnknown); show = show || (gInToSort); show = show || (tChildDir.GotStatus == GotStatus.Corrupt); show = show || !(gCorrect || gMissing || gUnknown || gInToSort || gFixes); if (!show) continue; rowCount++; int columnIndex = 0; for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++) { if (l >= 13) columnIndex = l; if (tDirStat.Get(RepairStatus.DisplayOrder[l]) <= 0) continue; int len = DigitLength(tDirStat.Get(RepairStatus.DisplayOrder[l])) * 7 + 26; if (len > _gameGridColumnXPositions[columnIndex]) _gameGridColumnXPositions[columnIndex] = len; columnIndex++; } } GameGrid.RowCount = rowCount; int t = 0; for (int l = 0; l < (int)RepStatus.EndValue; l++) { int colWidth = _gameGridColumnXPositions[l]; _gameGridColumnXPositions[l] = t; t += colWidth; } int row = 0; for (int j = 0; j < tDir.ChildCount; j++) { RvDir tChildDir = tDir.Child(j) as RvDir; if (tChildDir == null) continue; tDirStat = tChildDir.DirStatus; bool gCorrect = tDirStat.HasCorrect(); bool gMissing = tDirStat.HasMissing(); bool gUnknown = tDirStat.HasUnknown(); bool gFixes = tDirStat.HasFixesNeeded(); bool gInToSort = tDirStat.HasInToSort(); bool show = (chkBoxShowCorrect.Checked && gCorrect && !gMissing && !gFixes); show = show || (chkBoxShowMissing.Checked && gMissing); show = show || (chkBoxShowFixed.Checked && gFixes); show = show || (gUnknown); show = show || (gInToSort); show = show || (tChildDir.GotStatus == GotStatus.Corrupt); show = show || !(gCorrect || gMissing || gUnknown || gInToSort || gFixes); if (!show) continue; GameGrid.Rows[row].Selected = false; GameGrid.Rows[row].Tag = tChildDir; row++; } _updatingGameGrid = false; UpdateRomGrid(tDir); }