Cleaned up Natalia Portillo's Mess Bios xml Reader.
This commit is contained in:
@@ -14,41 +14,7 @@ using ROMVault2.Utils;
|
||||
namespace ROMVault2.DatReaders
|
||||
{
|
||||
public static class DatMessBIOSXmlReader
|
||||
{
|
||||
private static bool _cleanFileNames = 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)
|
||||
{
|
||||
for (int i = 0; i < dirNodeList.Count; i++)
|
||||
{
|
||||
LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType);
|
||||
}
|
||||
}
|
||||
|
||||
XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine");
|
||||
|
||||
if (machineNodeList != null)
|
||||
{
|
||||
for (int i = 0; i < machineNodeList.Count; i++)
|
||||
{
|
||||
LoadMachineFromDat(ref tDat, machineNodeList[i], thisFileType);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
public static bool ReadMessDat(ref RvDir tDat, XmlDocument doc)
|
||||
{
|
||||
FileType thisFileType = FileType.Unknown;
|
||||
@@ -101,13 +67,9 @@ namespace ROMVault2.DatReaders
|
||||
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");
|
||||
|
||||
tDat.AddData(RvDat.DatData.URL, VarFix.String(head.SelectSingleNode("url")));
|
||||
|
||||
|
||||
thisFileType = FileType.ZipFile;
|
||||
|
||||
// Look for: <romvault forcepacking="unzip"/>
|
||||
@@ -151,7 +113,7 @@ namespace ROMVault2.DatReaders
|
||||
}
|
||||
val = VarFix.String(packingNode.Attributes.GetNamedItem("dir")).ToLower(); // noautodir , nogame
|
||||
if (!String.IsNullOrEmpty(val))
|
||||
tDat.AddData(RvDat.DatData.DirSetup,val);
|
||||
tDat.AddData(RvDat.DatData.DirSetup, val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,25 +165,25 @@ namespace ROMVault2.DatReaders
|
||||
}
|
||||
else
|
||||
{
|
||||
RvDir tpDir = new RvDir(FileType.Dir)
|
||||
{
|
||||
Name = dir,
|
||||
DatStatus = DatStatus.InDatCollect,
|
||||
Dat = tDat.Dat,
|
||||
Tree = new RvTreeRow()
|
||||
};
|
||||
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()
|
||||
};
|
||||
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)
|
||||
@@ -257,44 +219,16 @@ namespace ROMVault2.DatReaders
|
||||
RvDir tDir;
|
||||
int index1 = 0;
|
||||
|
||||
string fullname = VarFix.CleanFullFileName(machineNode.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 fullname = VarFix.CleanFullFileName(machineNode.Attributes.GetNamedItem("name"));
|
||||
|
||||
fullname = fullname.Replace("/", "-");
|
||||
|
||||
tDir = new RvDir(DBTypeGet.DirFromFile(thisFileType))
|
||||
{
|
||||
Name = fullname,
|
||||
DatStatus = DatStatus.InDatCollect,
|
||||
Dat = tDat.Dat
|
||||
};
|
||||
|
||||
string testName = tDir.Name;
|
||||
int nameCount = 0;
|
||||
@@ -336,13 +270,13 @@ namespace ROMVault2.DatReaders
|
||||
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
|
||||
};
|
||||
RvDir tDirCHD = new RvDir(FileType.Dir)
|
||||
{
|
||||
Name = tDir.Name,
|
||||
DatStatus = tDir.DatStatus,
|
||||
Dat = tDir.Dat,
|
||||
Game = tDir.Game
|
||||
};
|
||||
|
||||
XmlNodeList romNodeList = machineNode.SelectNodes("rom");
|
||||
if (romNodeList != null)
|
||||
@@ -366,17 +300,17 @@ namespace ROMVault2.DatReaders
|
||||
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"))
|
||||
};
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user