Exemplo n.º 1
0
        private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            XmlNode name     = romNode.Attributes.GetNamedItem("name");
            string  loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag"));

            if (name != null)
            {
                RvRom rvRom = new RvRom();
                rvRom.Name   = VarFix.CleanFullFileName(name);
                rvRom.Size   = VarFix.ULong(romNode.Attributes.GetNamedItem("size"));
                rvRom.CRC    = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8);
                rvRom.SHA1   = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40);
                rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status"));

                _indexContinue = rvGame.AddRom(rvRom);
            }
            else if (loadflag.ToLower() == "continue")
            {
                RvRom tROM = rvGame.Roms[_indexContinue];
                tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size"));
            }
            else if (loadflag.ToLower() == "ignore")
            {
                RvRom tROM = rvGame.Roms[_indexContinue];
                tROM.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size"));
            }
        }
Exemplo n.º 2
0
        private static void LoadDirFromDat(RvDat rvDat, XmlNode dirNode, string rootDir, HeaderFileType datFileType)
        {
            if (dirNode.Attributes == null)
            {
                return;
            }

            string fullname = VarFix.CleanFullFileName(dirNode.Attributes.GetNamedItem("name"));

            XmlNodeList dirNodeList = dirNode.SelectNodes("dir");

            if (dirNodeList != null)
            {
                for (int i = 0; i < dirNodeList.Count; i++)
                {
                    LoadDirFromDat(rvDat, dirNodeList[i], Path.Combine(rootDir, fullname), datFileType);
                }
            }

            XmlNodeList gameNodeList = dirNode.SelectNodes("game");

            if (gameNodeList != null)
            {
                for (int i = 0; i < gameNodeList.Count; i++)
                {
                    LoadGameFromDat(rvDat, gameNodeList[i], Path.Combine(rootDir, fullname), datFileType);
                }
            }
        }
Exemplo n.º 3
0
        private static void LoadDiskFromDat(ref RvDir tGame, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }


            RvFile tRom = new RvFile(FileType.File)
            {
                Dat     = tGame.Dat,
                Name    = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")) + ".chd",
                SHA1CHD = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40),
                MD5CHD  = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32),
                Merge   = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge")),
                Status  = VarFix.ToLower(romNode.Attributes.GetNamedItem("status"))
            };

            if (tRom.SHA1CHD != null)
            {
                tRom.FileStatusSet(FileStatus.SHA1CHDFromDAT);
            }
            if (tRom.MD5CHD != null)
            {
                tRom.FileStatusSet(FileStatus.MD5CHDFromDAT);
            }

            tGame.ChildAdd(tRom);
        }
Exemplo n.º 4
0
        private static bool LoadRomFromDat(RvGame rvGame)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after rom", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }


            RvRom rvRom = new RvRom();

            rvRom.Name = VarFix.CleanFullFileName(DatFileLoader.Gn());
            DatFileLoader.Gn();


            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "size": rvRom.Size = VarFix.ULong(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

                case "crc": rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8); DatFileLoader.Gn(); break;

                case "sha1": rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break;

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

                case "merge": rvRom.Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

                case "flags": rvRom.Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

                case "date": DatFileLoader.Gn(); DatFileLoader.Gn(); break;

                case "bios": DatFileLoader.Gn(); DatFileLoader.Gn(); break;

                case "region": DatFileLoader.Gn(); DatFileLoader.Gn(); break;

                case "offs": DatFileLoader.Gn(); DatFileLoader.Gn(); break;

                case "nodump": rvRom.Status = "nodump"; DatFileLoader.Gn(); break;

                default:
                    DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in rom", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            rvGame.AddRom(rvRom);

            return(true);
        }
Exemplo n.º 5
0
        private static bool LoadDiskFromDat(ref RvDir tGame)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadRomFromDat_not_found_after_rom, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }


            string filename = VarFix.CleanFullFileName(DatFileLoader.Gn());
            RvFile tRom     = new RvFile(FileType.File)
            {
                Name = filename
            };

            DatFileLoader.Gn();
            tRom.Dat = tGame.Dat;

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "sha1": tRom.SHA1CHD = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40); DatFileLoader.Gn(); break;

                case "md5": tRom.MD5CHD = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break;

                case "merge": tRom.Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

                case "flags": tRom.Status = VarFix.ToLower(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

                case "nodump": tRom.Status = "nodump"; DatFileLoader.Gn(); break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadRomFromDat_not_known_in_rom, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            if (tRom.SHA1CHD != null)
            {
                tRom.FileStatusSet(FileStatus.SHA1CHDFromDAT);
            }
            if (tRom.MD5CHD != null)
            {
                tRom.FileStatusSet(FileStatus.MD5CHDFromDAT);
            }

            tGame.ChildAdd(tRom);

            return(true);
        }
Exemplo n.º 6
0
        private static bool LoadDirFromDat(RvDat rvDat, string rootName, HeaderFileType datFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }
            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            fullname = Path.Combine(rootName, fullname);

            DatFileLoader.Gn();

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "dir":
                    DatFileLoader.Gn();
                    if (!LoadDirFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "game":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "resource":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(rvDat, fullname, datFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error Keyword " + DatFileLoader.Next + " not know in dir", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        private static void LoadDiskFromDat(RvGame rvGame, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            string Name = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")) + ".chd";

            byte[] SHA1CHD = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40);
            byte[] MD5CHD  = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32);
            string Merge   = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge"));
            string Status  = VarFix.ToLower(romNode.Attributes.GetNamedItem("status"));
        }
Exemplo n.º 8
0
        private static bool LoadRomFromDat(ref RvDir tGame, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadRomFromDat_not_found_after_rom, DatFileLoader.Filename);
                return(false);
            }
            string line   = DatFileLoader.GnRest();
            string linelc = line.ToLower();

            int posName = linelc.IndexOf("name ", StringComparison.Ordinal);
            int posSize = linelc.IndexOf(" size ", posName + 5, StringComparison.Ordinal);
            int posDate = linelc.IndexOf(" date ", posSize + 6, StringComparison.Ordinal);
            int posCrc  = linelc.IndexOf(" crc ", posDate + 6, StringComparison.Ordinal);
            int posEnd  = linelc.IndexOf(" )", posCrc + 5, StringComparison.Ordinal);

            if (posName < 0 || posSize < 0 || posDate < 0 || posCrc < 0 || posEnd < 0)
            {
                DatFileLoader.Gn();
                return(false);
            }

            string name = line.Substring(posName + 5, posSize - (posName + 5));
            string size = line.Substring(posSize + 6, posDate - (posSize + 6));
            //string date = line.Substring(posDate + 6, posCrc - (posDate + 6));
            string crc = line.Substring(posCrc + 5, posEnd - (posCrc + 5));

            RvFile tRom = new RvFile(thisFileType)
            {
                Dat  = tGame.Dat,
                Name = VarFix.CleanFullFileName(name.Trim()),
                Size = VarFix.ULong(size.Trim()),
                CRC  = VarFix.CleanMD5SHA1(crc.Trim(), 8)
            };


            if (tRom.Size != null)
            {
                tRom.FileStatusSet(FileStatus.SizeFromDAT);
            }
            if (tRom.CRC != null)
            {
                tRom.FileStatusSet(FileStatus.CRCFromDAT);
            }

            tGame.ChildAdd(tRom);

            return(true);
        }
Exemplo n.º 9
0
        private static bool LoadDiskFromDat(RvGame rvGame)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after rom", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }


            string filename = VarFix.CleanFullFileName(DatFileLoader.Gn());

            byte[] sha1;
            byte[] md5;
            string Merge;
            string Status;

            DatFileLoader.Gn();

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

                case "md5": md5 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 32); DatFileLoader.Gn(); break;

                case "merge": Merge = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn(); break;

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

                case "nodump": Status = "nodump"; DatFileLoader.Gn(); break;

                default:
                    DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in rom", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 10
0
        private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode, FileType thisFileType)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            XmlNode name     = romNode.Attributes.GetNamedItem("name");
            string  loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag"));

            if (name != null)
            {
                RvFile tRom = new RvFile(thisFileType) // changed
                {
                    Name   = VarFix.CleanFullFileName(name),
                    Size   = VarFix.ULong(romNode.Attributes.GetNamedItem("size")),
                    CRC    = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8),
                    SHA1   = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40),
                    Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status")),

                    Dat = tGame.Dat
                };

                if (tRom.Size != null)
                {
                    tRom.FileStatusSet(FileStatus.SizeFromDAT);
                }
                if (tRom.CRC != null)
                {
                    tRom.FileStatusSet(FileStatus.CRCFromDAT);
                }
                if (tRom.SHA1 != null)
                {
                    tRom.FileStatusSet(FileStatus.SHA1FromDAT);
                }

                _indexContinue = tGame.ChildAdd(tRom);
            }
            else if (loadflag.ToLower() == "continue")
            {
                RvFile tZippedFile = (RvFile)tGame.Child(_indexContinue);
                tZippedFile.Size += VarFix.ULong(romNode.Attributes.GetNamedItem("size"));
            }
        }
Exemplo n.º 11
0
        private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            RvRom rvRom = new RvRom();

            rvRom.Name   = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name"));
            rvRom.Size   = VarFix.ULong(romNode.Attributes.GetNamedItem("size"));
            rvRom.CRC    = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("crc"), 8);
            rvRom.SHA1   = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("sha1"), 40);
            rvRom.MD5    = VarFix.CleanMD5SHA1(romNode.Attributes.GetNamedItem("md5"), 32);
            rvRom.Merge  = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("merge"));
            rvRom.Status = VarFix.ToLower(romNode.Attributes.GetNamedItem("status"));

            rvGame.AddRom(rvRom);
        }
Exemplo n.º 12
0
        private static void LoadRomFromDat(RvGame rvGame, XmlNode romNode, HeaderFileType datFileType)
        {
            if (romNode.Attributes == null)
            {
                return;
            }

            RvRom rvRom = new RvRom
            {
                AltType = datFileType,
                Name    = VarFix.CleanFullFileName(romNode.Attributes.GetNamedItem("name")),
                Size    = VarFix.ULong(romNode.Attributes.GetNamedItem("size")),
                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"))
            };

            rvGame.AddRom(rvRom);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        private static bool LoadGameFromDat(ref RvDir tDat, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (_cleanFileNames)
            {
                fullname = fullname.Replace("/", "-");
            }

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                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;
                }
            }

            if (fullname.Length > 4 && fullname.ToLower().Substring(fullname.Length - 4, 4) == ".zip")
            {
                fullname = fullname.Substring(0, fullname.Length - 4);
            }

            RvDir tDir = new RvDir(thisFileType == FileType.File ? FileType.Dir : FileType.Zip)
            {
                Name = fullname
            };

            DatFileLoader.Gn();
            tDir.Game      = new RvGame();
            tDir.DatStatus = DatStatus.InDatCollect;
            tDir.Dat       = tDat.Dat;
            int index1;

            string testName  = tDir.Name;
            int    nameCount = 0;

            while (parent.ChildNameSearch(tDir, out index1) == 0)
            {
                tDir.Name = testName + "_" + nameCount;
                nameCount++;
            }
            parent.ChildAdd(tDir, index1);


            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "file":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(ref tDir, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadGameFromDat_not_known_in_game, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }


            return(true);
        }
Exemplo n.º 15
0
        private static bool LoadGameFromDat(RvDat rvDat, string rootName, HeaderFileType datFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

            DatFileLoader.Gn();
            string snext     = DatFileLoader.Next.ToLower();
            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn());
                DatFileLoader.Gn();
                snext = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( ) on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

            string name = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            name = Path.Combine(pathextra, name);
            name = Path.Combine(rootName, name);
            name = (name.EndsWith(".zip") ? name.Remove(name.Length - 4) : name);

            DatFileLoader.Gn();
            RvGame rvGame = new RvGame {
                Name = name
            };

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof":
                    rvGame.RomOf = VarFix.CleanFileName(DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "description":
                    rvGame.Description = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sourcefile":
                    rvGame.SourceFile = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "cloneof":
                    rvGame.CloneOf = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sampleof":
                    rvGame.SampleOf = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "board":
                    rvGame.Board = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "year":
                    rvGame.Year = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "manufacturer":
                    rvGame.Manufacturer = DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "serial":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "rebuildto":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sample":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "biosset":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "chip":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "video":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sound":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "input":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "dipswitch":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "driver":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "file":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(rvGame, datFileType))
                    {
                        return(false);
                    }

                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error on line " + DatFileLoader.LineNumber + ": key word '" + DatFileLoader.Next + "' not known in game", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            rvDat.AddGame(rvGame);
            return(true);
        }
Exemplo n.º 16
0
        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);
                }
            }
        }
Exemplo n.º 17
0
        private static void LoadGameFromDat(RvDat rvDat, XmlNode gameNode, string rootDir, HeaderFileType datFileType)
        {
            if (gameNode.Attributes == null)
            {
                return;
            }

            RvGame rvGame = new RvGame
            {
                Name         = VarFix.CleanFullFileName(gameNode.Attributes.GetNamedItem("name")),
                RomOf        = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("romof")),
                CloneOf      = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("cloneof")),
                SampleOf     = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("sampleof")),
                Description  = VarFix.String(gameNode.SelectSingleNode("description")),
                SourceFile   = VarFix.String(gameNode.Attributes.GetNamedItem("sourcefile")),
                IsBios       = VarFix.String(gameNode.Attributes.GetNamedItem("isbios")),
                Board        = VarFix.String(gameNode.Attributes.GetNamedItem("board")),
                Year         = VarFix.String(gameNode.SelectSingleNode("year")),
                Manufacturer = VarFix.String(gameNode.SelectSingleNode("manufacturer"))
            };

            XmlNode trurip = gameNode.SelectSingleNode("trurip");

            if (trurip != null)
            {
                rvGame.IsTrurip           = true;
                rvGame.Publisher          = VarFix.String(trurip.SelectSingleNode("publisher"));
                rvGame.Developer          = VarFix.String(trurip.SelectSingleNode("developer"));
                rvGame.Edition            = VarFix.String(trurip.SelectSingleNode("edition"));
                rvGame.Version            = VarFix.String(trurip.SelectSingleNode("version"));
                rvGame.Type               = VarFix.String(trurip.SelectSingleNode("type"));
                rvGame.Media              = VarFix.String(trurip.SelectSingleNode("media"));
                rvGame.Language           = VarFix.String(trurip.SelectSingleNode("language"));
                rvGame.Players            = VarFix.String(trurip.SelectSingleNode("players"));
                rvGame.Ratings            = VarFix.String(trurip.SelectSingleNode("ratings"));
                rvGame.Peripheral         = VarFix.String(trurip.SelectSingleNode("peripheral"));
                rvGame.Genre              = VarFix.String(trurip.SelectSingleNode("genre"));
                rvGame.MediaCatalogNumber = VarFix.String(trurip.SelectSingleNode("mediacatalognumber"));
                rvGame.BarCode            = VarFix.String(trurip.SelectSingleNode("barcode"));
            }

            rvGame.Name = Path.Combine(rootDir, rvGame.Name);

            rvDat.AddGame(rvGame);

            XmlNodeList romNodeList = gameNode.SelectNodes("rom");

            if (romNodeList != null)
            {
                for (int i = 0; i < romNodeList.Count; i++)
                {
                    LoadRomFromDat(rvGame, romNodeList[i], datFileType);
                }
            }

            XmlNodeList diskNodeList = gameNode.SelectNodes("disk");

            if (diskNodeList != null)
            {
                for (int i = 0; i < diskNodeList.Count; i++)
                {
                    LoadDiskFromDat(rvGame, diskNodeList[i]);
                }
            }
        }
Exemplo n.º 18
0
        private static bool LoadGameFromDat(RvDat rvDat, string rootdir)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after game", DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn()); DatFileLoader.Gn();
                snext     = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat("Name not found as first object in ( )", DatFileLoader.Filename);
                return(false);
            }


            string name = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (!String.IsNullOrEmpty(pathextra))
            {
                name = pathextra + "/" + name;
            }

            DatFileLoader.Gn();

            RvGame rvGame = new RvGame();

            rvGame.Name = name;
            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof": rvGame.RomOf = VarFix.CleanFileName(DatFileLoader.GnRest()); DatFileLoader.Gn(); break;

                case "description": rvGame.Description = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sourcefile": rvGame.SourceFile = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "cloneof": rvGame.CloneOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sampleof": rvGame.SampleOf = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "board": rvGame.Board = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "year": rvGame.Year = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "manufacturer": rvGame.Manufacturer = DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "serial": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "rebuildto": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sample": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "biosset": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "chip": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "video": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "sound": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "input": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "dipswitch": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;

                case "driver": DatFileLoader.GnRest(); DatFileLoader.Gn(); break;


                case "rom":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(rvGame))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "disk":
                    DatFileLoader.Gn();
                    if (!LoadDiskFromDat(rvGame))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "archive":
                    DatFileLoader.Gn();
                    if (!LoadArchiveFromDat())
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat("Error: key word '" + DatFileLoader.Next + "' not known in game", DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            rvDat.AddGame(rvGame);
            return(true);
        }
Exemplo n.º 19
0
        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);
            }
        }
Exemplo n.º 20
0
        private static bool LoadGameFromDat(ref RvDir tDat, bool bolresource, FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            string snext = DatFileLoader.Next.ToLower();

            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = VarFix.CleanFullFileName(DatFileLoader.Gn());
                DatFileLoader.Gn();
                snext = DatFileLoader.Next.ToLower();
            }

            if (snext != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            if (_cleanFileNames)
            {
                fullname = fullname.Replace("/", "-");
            }

            if (!string.IsNullOrEmpty(pathextra))
            {
                fullname = pathextra + "/" + fullname;
            }

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                fullname = fullname.Substring(firstSlash + 1);
                if (parent.ChildNameSearch(new RvDir(FileType.Dir)
                {
                    Name = dir
                }, out int 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(thisFileType == FileType.File ? FileType.Dir : FileType.Zip)
            {
                Name      = fullname,
                DatStatus = DatStatus.InDatCollect,
                Dat       = tDat.Dat
            };

            string testName  = tDir.Name;
            int    nameCount = 0;
            int    index1;

            while (parent.ChildNameSearch(tDir, out index1) == 0)
            {
                tDir.Name = testName + "_" + nameCount;
                nameCount++;
            }

            DatFileLoader.Gn();
            tDir.Game = new RvGame();
            tDir.Game.AddData(RvGame.GameData.IsBios, bolresource ? "Yes" : "No");

            RvDir tDirCHD = new RvDir(FileType.Dir)
            {
                Name      = tDir.Name,
                DatStatus = tDir.DatStatus,
                Dat       = tDir.Dat,
                Game      = tDir.Game
            };

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "romof":
                    tDir.Game.AddData(RvGame.GameData.RomOf, VarFix.CleanFileName(DatFileLoader.GnRest()));
                    DatFileLoader.Gn();
                    break;

                case "description":
                    tDir.Game.AddData(RvGame.GameData.Description, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "sourcefile":
                    tDir.Game.AddData(RvGame.GameData.Sourcefile, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "cloneof":
                    tDir.Game.AddData(RvGame.GameData.CloneOf, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "sampleof":
                    tDir.Game.AddData(RvGame.GameData.SampleOf, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "board":
                    tDir.Game.AddData(RvGame.GameData.Board, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "year":
                    tDir.Game.AddData(RvGame.GameData.Year, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "manufacturer":
                    tDir.Game.AddData(RvGame.GameData.Manufacturer, DatFileLoader.GnRest());
                    DatFileLoader.Gn();
                    break;

                case "serial":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "rebuildto":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sample":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "biosset":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "chip":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "video":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "sound":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "input":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "dipswitch":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;

                case "driver":
                    DatFileLoader.GnRest();
                    DatFileLoader.Gn();
                    break;


                case "rom":
                    DatFileLoader.Gn();
                    if (!LoadRomFromDat(ref tDir, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "disk":
                    DatFileLoader.Gn();
                    if (!LoadDiskFromDat(ref tDirCHD))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "archive":
                    DatFileLoader.Gn();
                    if (!LoadArchiveFromDat())
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_ReadDat_Error_keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadGameFromDat_not_known_in_game, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }

            if (tDir.ChildCount > 0)
            {
                parent.ChildAdd(tDir, index1);
            }
            if (tDirCHD.ChildCount > 0)
            {
                parent.ChildAdd(tDirCHD);
            }

            return(true);
        }
Exemplo n.º 21
0
        private static bool LoadDirFromDat(ref RvDir tDat, ref FileType thisFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_not_found_after_game, DatFileLoader.Filename);
                return(false);
            }
            DatFileLoader.Gn();

            if (DatFileLoader.Next.ToLower() != "name")
            {
                DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadGameFromDat_Name_not_found_as_first_object_in, DatFileLoader.Filename);
                return(false);
            }

            RvDir parent = tDat;

            string fullname = VarFix.CleanFullFileName(DatFileLoader.GnRest());

            while (fullname.Contains("/"))
            {
                int    firstSlash = fullname.IndexOf("/", StringComparison.Ordinal);
                string dir        = fullname.Substring(0, firstSlash);
                dir = VarFix.CleanFileName(dir);

                fullname = fullname.Substring(firstSlash + 1);
                if (parent.ChildNameSearch(new RvDir(FileType.Dir)
                {
                    Name = dir
                }, out int 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
            };

            DatFileLoader.Gn();
            tDir.DatStatus = DatStatus.InDatCollect;
            tDir.Dat       = tDat.Dat;

            if (parent.ChildNameSearch(tDir, out int index1) == 0)
            {
                tDir = (RvDir)parent.Child(index1);
            }
            else
            {
                parent.ChildAdd(tDir, index1);
            }

            while (DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "dir":
                    DatFileLoader.Gn();
                    if (!LoadDirFromDat(ref tDir, ref thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "game":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(ref tDir, false, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                case "resource":
                    DatFileLoader.Gn();
                    if (!LoadGameFromDat(ref tDir, true, thisFileType))
                    {
                        return(false);
                    }
                    DatFileLoader.Gn();
                    break;

                default:
                    DatUpdate.SendAndShowDat(Resources.DatCmpReader_LoadDirFromDat_Error_Keyword + DatFileLoader.Next + Resources.DatCmpReader_LoadDirFromDat_not_know_in_dir, DatFileLoader.Filename);
                    DatFileLoader.Gn();
                    break;
                }
            }
            return(true);
        }
Exemplo n.º 22
0
        private static bool LoadRomFromDat(RvGame rvGame, HeaderFileType datFileType)
        {
            if (DatFileLoader.Next != "(")
            {
                DatUpdate.SendAndShowDat("( not found after rom on line " + DatFileLoader.LineNumber, DatFileLoader.Filename);
                return(false);
            }

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

            RvRom rvRom = new RvRom
            {
                Name    = VarFix.CleanFullFileName(DatFileLoader.Gn()),
                AltType = datFileType
            };

            DatFileLoader.Gn();
            while (rvRom.CRC == null || rvRom.Size == null || DatFileLoader.Next != ")")
            {
                switch (DatFileLoader.Next.ToLower())
                {
                case "size":
                    rvRom.Size = VarFix.ULong(DatFileLoader.Gn());
                    DatFileLoader.Gn();
                    break;

                case "crc":
                    rvRom.CRC = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 8);
                    DatFileLoader.Gn();
                    break;

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

                case "sha1":
                    rvRom.SHA1 = VarFix.CleanMD5SHA1(DatFileLoader.Gn(), 40);
                    DatFileLoader.Gn();
                    break;

                case "sha256":
                    // No-op until larger hashes are supported
                    DatFileLoader.Gn();
                    DatFileLoader.Gn();
                    break;

                case "sha384":
                    // No-op until larger hashes are supported
                    DatFileLoader.Gn();
                    DatFileLoader.Gn();
                    break;

                case "sha512":
                    // No-op until larger hashes are supported
                    DatFileLoader.Gn();
                    DatFileLoader.Gn();
                    break;

                case "date":
                    rvRom.Date  = DatFileLoader.Gn();
                    rvRom.Date += " " + DatFileLoader.Gn();
                    DatFileLoader.Gn();
                    break;

                default:
                    rvRom.Name += " " + DatFileLoader.Next;
                    DatFileLoader.Gn();
                    break;
                }
            }

            rvGame.AddRom(rvRom);
            return(true);
        }