Ejemplo n.º 1
0
        private bool LoadFileFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after file, 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 = dfl.GnNameToSize()
            };

            dfl.Gn();


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

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

                case "date":
                    dRom.Date = dfl.Gn() + " " + dfl.Gn();
                    dfl.Gn();
                    break;

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

            parentDir.ChildAdd(dRom);

            return(true);
        }