public static bool ReadDat(string strFilename, ReportError errorReport, out DatHeader datHeader) { using (DatFileLoader dfl = new DatFileLoader()) { datHeader = new DatHeader { BaseDir = new DatDir(DatFileType.UnSet) }; int errorCode = dfl.LoadDat(strFilename, DatRead.Enc); if (errorCode != 0) { errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message); return(false); } dfl.Gn(); if (dfl.EndOfStream()) { return(false); } if (dfl.Next.ToLower() == "clrmamepro" || dfl.Next.ToLower() == "clrmame") { if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport)) { return(false); } dfl.Gn(); } if (dfl.Next.ToLower() == "raine") { while (dfl.Next.ToLower() != "emulator") { dfl.Gn(); } if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport)) { return(false); } dfl.Gn(); } if (dfl.Next.ToLower() == "romvault") { if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport)) { return(false); } dfl.Gn(); } while (!dfl.EndOfStream()) { bool res = ReadNextBlock(dfl, datHeader.BaseDir, errorReport); if (!res) { return(false); } } } return(true); }
public bool ReadDat(string strFilename, out DatHeader datHeader) { _filename = strFilename; using (DatFileLoader dfl = new DatFileLoader()) { datHeader = new DatHeader { BaseDir = new DatDir(DatFileType.UnSet) }; int errorCode = dfl.LoadDat(strFilename, System.Text.Encoding.UTF8); if (errorCode != 0) { _errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message); return(false); } dfl.Gn(); if (dfl.EndOfStream()) { return(false); } if (dfl.Next.ToLower() == "doscenter") { dfl.Gn(); if (!LoadHeaderFromDat(dfl, datHeader)) { return(false); } dfl.Gn(); } while (!dfl.EndOfStream()) { switch (dfl.Next.ToLower()) { case "game": dfl.Gn(); if (!LoadGameFromDat(dfl, datHeader.BaseDir)) { return(false); } dfl.Gn(); break; default: _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known, on line " + dfl.LineNumber); dfl.Gn(); break; } } } return(true); }
public bool ReadDat(string strFilename, out DatHeader datHeader) { _filename = strFilename; using (DatFileLoader dfl = new DatFileLoader()) { datHeader = new DatHeader { BaseDir = new DatDir(DatFileType.UnSet) }; int errorCode = dfl.LoadDat(strFilename); if (errorCode != 0) { _errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message); return(false); } dfl.Gn(); if (dfl.EndOfStream()) { return(false); } if (dfl.Next.ToLower() == "clrmamepro" || dfl.Next.ToLower() == "clrmame") { dfl.Gn(); if (!LoadHeaderFromDat(dfl, datHeader)) { return(false); } dfl.Gn(); } if (dfl.Next.ToLower() == "romvault") { dfl.Gn(); if (!LoadHeaderFromDat(dfl, datHeader)) { return(false); } dfl.Gn(); } while (!dfl.EndOfStream()) { bool res = ReadNextBlock(dfl, datHeader.BaseDir); if (!res) { return(false); } } } return(true); }
public static bool ReadDat(string strFilename, ReportError errorReport, out DatHeader datHeader) { datHeader = new DatHeader { BaseDir = new DatDir(DatFileType.UnSet), Filename = strFilename }; using (DatFileLoader dfl = new DatFileLoader()) { dfl.LoadDat(strFilename); dfl.Gn(); while (!dfl.EndOfStream()) { switch (dfl.Next.ToLower()) { case "[credits]": //getcredits if (!LoadCredits(dfl, datHeader, errorReport)) { return(false); } break; case "[dat]": //getdat if (!LoadDat(dfl, datHeader, errorReport)) { return(false); } break; case "[emulator]": //emulator if (!LoadEmulator(dfl, datHeader, errorReport)) { return(false); } break; case "[games]": //games if (!LoadGame(dfl, datHeader.BaseDir, errorReport)) { return(false); } break; case "[resources]": //resources if (!LoadGame(dfl, datHeader.BaseDir, errorReport)) { return(false); } break; case "[disks]": //games if (!LoadDisks(dfl, datHeader.BaseDir, errorReport)) { return(false); } break; default: errorReport?.Invoke(dfl.Filename, "Unknown Line " + dfl.Next + " , " + dfl.LineNumber); return(false); } } } return(true); }