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); }
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 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); }
private static bool RecursiveDatTree(RvFile tDir, out int datCount) { datCount = 0; string strPath = RvFile.GetDatPhysicalPath(tDir.DatTreeFullName); if (!Directory.Exists(strPath)) { ReportError.Show("Path: " + strPath + " Not Found."); return(false); } DirectoryInfo oDir = new DirectoryInfo(strPath); List <FileInfo> lFilesIn = new List <FileInfo>(); FileInfo[] oFilesIn = oDir.GetFiles("*.dat"); lFilesIn.AddRange(oFilesIn); oFilesIn = oDir.GetFiles("*.xml"); lFilesIn.AddRange(oFilesIn); datCount += lFilesIn.Count; foreach (FileInfo file in lFilesIn) { RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatRootFullName, Path.Combine(tDir.DatTreeFullName, file.Name)); tDat.TimeStamp = file.LastWriteTime; string datRootFullName = tDat.GetData(RvDat.DatData.DatRootFullName); DatRule datRule = DatReader.FindDatRule(datRootFullName); tDat.MultiDatOverride = datRule.MultiDATDirOverride; tDat.UseDescriptionAsDirName = datRule.UseDescriptionAsDirName; tDat.SingleArchive = datRule.SingleArchive; tDat.RemoveSubDir = datRule.RemoveSubDir; tDir.DirDatAdd(tDat); } if (tDir.DirDatCount > 1) { for (int i = 0; i < tDir.DirDatCount; i++) { tDir.DirDat(i).MultiDatsInDirectory = true; } } DirectoryInfo[] oSubDir = oDir.GetDirectories(); foreach (DirectoryInfo t in oSubDir) { RvFile cDir = new RvFile(FileType.Dir) { Name = t.Name, DatStatus = DatStatus.InDatCollect }; int index = tDir.ChildAdd(cDir); RecursiveDatTree(cDir, out int retDatCount); datCount += retDatCount; if (retDatCount == 0) { tDir.ChildRemove(index); } } return(true); }
private static bool RecursiveDatTree(RvDir tDir, out int datCount) { datCount = 0; string strPath = tDir.DatFullName; if (!Directory.Exists(strPath)) { ReportError.Show(Resources.DatUpdate_UpdateDatList_Path + strPath + Resources.DatUpdate_UpdateDatList_Not_Found); return(false); } DirectoryInfo oDir = new DirectoryInfo(strPath); FileInfo[] oFilesIn = oDir.GetFiles("*.dat", false); datCount += oFilesIn.Length; foreach (FileInfo file in oFilesIn) { RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatFullName, file.FullName); tDat.TimeStamp = file.LastWriteTime; tDir.DirDatAdd(tDat); } oFilesIn = oDir.GetFiles("*.xml", false); datCount += oFilesIn.Length; foreach (FileInfo file in oFilesIn) { RvDat tDat = new RvDat(); tDat.AddData(RvDat.DatData.DatFullName, file.FullName); tDat.TimeStamp = file.LastWriteTime; tDir.DirDatAdd(tDat); } if (tDir.DirDatCount > 1) { for (int i = 0; i < tDir.DirDatCount; i++) { tDir.DirDat(i).AutoAddDirectory = true; } } DirectoryInfo[] oSubDir = oDir.GetDirectories(false); foreach (DirectoryInfo t in oSubDir) { RvDir cDir = new RvDir(FileType.Dir) { Name = t.Name, DatStatus = DatStatus.InDatCollect }; int index = tDir.ChildAdd(cDir); int retDatCount; RecursiveDatTree(cDir, out retDatCount); datCount += retDatCount; if (retDatCount == 0) { tDir.ChildRemove(index); } } return(true); }
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(); string forceZipping = ""; RvDat tDat = new RvDat(); while (DatFileLoader.Next != ")") { switch (DatFileLoader.Next.ToLower()) { 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 "category": tDat.AddData(RvDat.DatData.Category, 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 "email": tDat.AddData(RvDat.DatData.Email, DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "homepage": tDat.AddData(RvDat.DatData.HomePage, DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "url": tDat.AddData(RvDat.DatData.URL, DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "comment": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "header": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "forcezipping": forceZipping = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "forcepacking": forceZipping = DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "forcemerging": tDat.AddData(RvDat.DatData.MergeType, DatFileLoader.GnRest()); DatFileLoader.Gn(); break; case "forcenodump": DatFileLoader.GnRest(); DatFileLoader.Gn(); break; case "dir": tDat.AddData(RvDat.DatData.DirSetup, 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 = (forceZipping.ToLower() != "no") && (forceZipping.ToLower() != "unzip") ? FileType.ZipFile : FileType.File; tDir.Dat = tDat; return(true); }
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); }
public static RvFile ConvertFromExternalDat(DatHeader datHeaderExternal, RvDat datFile) { RvFile newDirFromExternal = new RvFile(FileType.Dir); RvDat newDatFromExternal = new RvDat(); newDatFromExternal.AddData(RvDat.DatData.DatRootFullName, datFile.GetData(RvDat.DatData.DatRootFullName)); newDatFromExternal.TimeStamp = datFile.TimeStamp; newDatFromExternal.Status = DatUpdateStatus.Correct; newDatFromExternal.AddData(RvDat.DatData.DatName, datHeaderExternal.Name); newDatFromExternal.AddData(RvDat.DatData.RootDir, datHeaderExternal.RootDir); newDatFromExternal.AddData(RvDat.DatData.Description, datHeaderExternal.Description); newDatFromExternal.AddData(RvDat.DatData.Category, datHeaderExternal.Category); newDatFromExternal.AddData(RvDat.DatData.Version, datHeaderExternal.Version); newDatFromExternal.AddData(RvDat.DatData.Date, datHeaderExternal.Date); newDatFromExternal.AddData(RvDat.DatData.Author, datHeaderExternal.Author); newDatFromExternal.AddData(RvDat.DatData.Email, datHeaderExternal.Email); newDatFromExternal.AddData(RvDat.DatData.HomePage, datHeaderExternal.Homepage); newDatFromExternal.AddData(RvDat.DatData.URL, datHeaderExternal.URL); newDatFromExternal.AddData(RvDat.DatData.DirSetup, datHeaderExternal.Dir); newDatFromExternal.AddData(RvDat.DatData.Header, datHeaderExternal.Header); newDatFromExternal.MultiDatsInDirectory = datFile.MultiDatsInDirectory; newDatFromExternal.MultiDatOverride = datFile.MultiDatOverride; newDirFromExternal.Dat = newDatFromExternal; HeaderFileType headerFileType = FileHeaderReader.FileHeaderReader.GetFileTypeFromHeader(datHeaderExternal.Header); CopyDir(datHeaderExternal.BaseDir, newDirFromExternal, newDatFromExternal, headerFileType, false); return(newDirFromExternal); }