示例#1
0
        private static void LoadDiskFromDat(DatDir parentDir, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            DatFile dRom = new DatFile(DatFileType.UnSet)
            {
                Name   = VarFix.CleanCHD(romNode.Attributes.GetNamedItem("name")),
                SHA1   = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40),
                Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")),
                isDisk = true
            };

            parentDir.ChildAdd(dRom);
        }
示例#2
0
        private static void LoadDiskFromDat(DatDir parentDir, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            DatFile rvRom = new DatFile(DatFileType.UnSet)
            {
                Name   = VarFix.CleanCHD(romNode.Attributes.GetNamedItem("name")),
                SHA1   = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40),
                MD5    = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32),
                Merge  = VarFix.String(romNode.Attributes.GetNamedItem("merge")),
                Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")),
                isDisk = true
            };

            if (!string.IsNullOrWhiteSpace(rvRom.Merge))
            {
                rvRom.Merge += ".chd";
            }

            parentDir.ChildAdd(rvRom);
        }
示例#3
0
        private static bool LoadDisks(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            if (dfl.Next.ToLower() != "[disks]")
            {
                errorReport?.Invoke(dfl.Filename, "Looking for [DISKS] but found " + dfl.Next + " , " + dfl.LineNumber);
                return(false);
            }

            while (!dfl.EndOfStream())
            {
                string line = dfl.Gn();

                if (line.Substring(0, 1) == "[")
                {
                    return(true);
                }

                string[] parts = line.Split('¬');

                // 1 parent name         = clone of
                // 2 parent description  = description (from parent)
                // 3 game name           = name (game)
                // 4 game description    = description
                // 5 rom name            = name (rom)
                // 6 rom crc             = crc
                // 7 rom size            = size
                // 8 romof name          = romof
                // 9 merge name          = merge

                string ParentName        = parts[1];
                string ParentDescription = parts[2];
                string GameName          = parts[3];
                string GameDescription   = parts[4];
                string romName           = parts[5];
                string romCRC            = parts[6];
                string romSize           = parts[7];
                string romOf             = parts[8];
                string merge             = parts[9];

                int    index;
                DatDir dDir;
                DatDir searchDir = new DatDir(DatFileType.Dir)
                {
                    Name = GameName
                };
                if (parentDir.ChildNameSearch(searchDir, out index) != 0)
                {
                    dDir = new DatDir(DatFileType.UnSet)
                    {
                        Name = GameName, DGame = new DatGame()
                    };
                    DatGame dGame = dDir.DGame;
                    dGame.Description = GameDescription;
                    if (ParentName != GameName)
                    {
                        dGame.CloneOf = ParentName;
                    }
                    parentDir.ChildAdd(dDir);
                }
                else
                {
                    dDir = (DatDir)parentDir.Child(index);
                    // need to check everything matches
                }

                DatFile dRom = new DatFile(DatFileType.UnSet)
                {
                    isDisk = true,
                    Name   = VarFix.CleanCHD(romName),
                    SHA1   = VarFix.CleanMD5SHA1(romCRC, 40),
                    Merge  = merge
                };
                // dRom.Size = VarFix.ULong(romSize);
                // check romof=ParentName

                dDir.ChildAdd(dRom);
            }
            return(true);
        }
示例#4
0
        private static bool LoadDiskFromDat(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                errorReport?.Invoke(dfl.Filename, "( not found after rom, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            if (dfl.Next.ToLower() != "name")
            {
                errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }

            DatFile dRom = new DatFile(DatFileType.UnSet)
            {
                Name   = VarFix.CleanCHD(dfl.Gn()),
                isDisk = true
            };

            dfl.Gn();
            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "sha1":
                    dRom.SHA1 = VarFix.CleanMD5SHA1(dfl.Gn(), 40);
                    break;

                case "md5":
                    dRom.MD5 = VarFix.CleanMD5SHA1(dfl.Gn(), 32);
                    break;

                case "region":
                    dRom.Region = VarFix.String(dfl.Gn());
                    break;

                case "merge":
                    dRom.Merge = VarFix.String(dfl.Gn());
                    break;

                case "index":
                    dfl.Gn();
                    break;

                case "flags":
                    dRom.Status = VarFix.ToLower(dfl.Gn());
                    break;

                case "nodump":
                    dRom.Status = "nodump";
                    break;

                default:
                    errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }
            parentDir.ChildAdd(dRom);

            return(true);
        }