Esempio n. 1
0
        public static bool RemoveEmptySets(DatBase inDat)
        {
            if (inDat is DatFile)
            {
                return(true);
            }

            DatDir dDir = inDat as DatDir;

            DatBase[] children = dDir?.ToArray();
            if (children == null || children.Length == 0)
            {
                return(false);
            }

            dDir.ChildrenClear();

            bool found = false;

            foreach (DatBase child in children)
            {
                bool keep = RemoveEmptySets(child);
                if (keep)
                {
                    found = true;
                    dDir.ChildAdd(child);
                }
            }

            return(found);
        }
Esempio n. 2
0
        public static bool RemoveNotCollected(DatBase inDat)
        {
            if (inDat is DatFile dFile)
            {
                return(dFile.DatStatus == DatFileStatus.InDatCollect || dFile.DatStatus == DatFileStatus.InDatBad);
            }

            DatDir dDir = inDat as DatDir;

            DatBase[] children = dDir?.ToArray();
            if (children == null || children.Length == 0)
            {
                return(false);
            }

            dDir.ChildrenClear();

            bool found = false;

            foreach (DatBase child in children)
            {
                bool keep = RemoveNotCollected(child);
                if (keep)
                {
                    found = true;
                    dDir.ChildAdd(child);
                }
            }

            return(found);
        }
        public static void RemoveDevices(DatDir tDat)
        {
            DatBase[] children = tDat.ToArray();

            tDat.ChildrenClear();
            foreach (DatBase child in children)
            {
                DatDir mGame = (DatDir)child;

                if (mGame.DGame == null)
                {
                    RemoveDevices(mGame);
                    tDat.ChildAdd(mGame);
                }
                else
                {
                    DatGame dGame = mGame.DGame;

                    if (dGame != null && dGame.IsDevice == "yes" && dGame.Runnable == "no")
                    {
                        continue;
                    }

                    tDat.ChildAdd(mGame);
                }
            }
        }
Esempio n. 4
0
        public static void CleanFilenamesFixDupes(DatDir dDir)
        {
            DatBase[] arrDir     = dDir.ToArray();
            string    lastName   = "";
            int       matchCount = 0;

            foreach (DatBase db in arrDir)
            {
                string thisName = db.Name;
                if (lastName == thisName)
                {
                    string path0 = Path.GetFileNameWithoutExtension(thisName);
                    string path1 = Path.GetExtension(thisName);
                    db.Name     = path0 + "_" + matchCount + path1;
                    matchCount += 1;
                }
                else
                {
                    matchCount = 0;
                    lastName   = thisName;
                }

                if (db is DatDir ddir)
                {
                    CleanFilenamesFixDupes(ddir);
                }
            }
        }
Esempio n. 5
0
        public static void CleanFilenames(DatDir dDir)
        {
            DatBase[] arrDir = dDir.ToArray();
            foreach (DatBase db in arrDir)
            {
                CleanFilename(db);

                if (db is DatDir ddir)
                {
                    CleanFilenames(ddir);
                }
            }
        }
Esempio n. 6
0
        public static void RemoveDeviceRef(DatDir dDir)
        {
            DatBase[] arrDir = dDir.ToArray();
            if (arrDir == null)
            {
                return;
            }

            foreach (DatBase db in arrDir)
            {
                if (db is DatDir ddir)
                {
                    if (ddir.DGame != null)
                    {
                        ddir.DGame.device_ref = null;
                    }
                    RemoveDeviceRef(ddir);
                }
            }
        }
Esempio n. 7
0
        public static void RemoveNoDumps(DatDir tDat)
        {
            for (int g = 0; g < tDat.ChildCount; g++)
            {
                DatDir mGame = (DatDir)tDat.Child(g);

                if (mGame.DGame == null)
                {
                    RemoveNoDumps(mGame);
                }
                else
                {
                    DatBase[] tGame = mGame.ToArray();
                    foreach (DatBase t in tGame)
                    {
                        if (((DatFile)t).Status == "nodump")
                        {
                            mGame.ChildRemove(t);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public static void CleanFilenamesFixDupes(DatDir dDir)
        {
            DatBase[]   arrDir       = dDir.ToArray();
            string      lastName     = "";
            DatFileType lastFileType = DatFileType.UnSet;
            int         matchCount   = 0;

            foreach (DatBase db in arrDir)
            {
                string      thisName = db.Name;
                DatFileType fileType = db.DatFileType;

                if (lastFileType == fileType && lastName.ToLowerInvariant() == thisName.ToLowerInvariant())
                {
                    Debug.WriteLine("Found match = " + lastName + " , " + thisName);

                    string path1 = Path.GetExtension(thisName);
                    string path0 = thisName.Substring(0, thisName.Length - path1.Length);

                    db.Name = path0 + "_" + matchCount + path1;
                    Debug.WriteLine("New filename = " + db.Name);
                    matchCount += 1;
                }
                else
                {
                    matchCount   = 0;
                    lastName     = thisName;
                    lastFileType = fileType;
                }

                if (db is DatDir ddir)
                {
                    CleanFilenamesFixDupes(ddir);
                }
            }
        }
Esempio n. 9
0
        public static void DirectoryExpand(DatDir dDir)
        {
            DatBase[] arrDir      = dDir.ToArray();
            bool      foundSubDir = false;

            foreach (DatBase db in arrDir)
            {
                if (CheckDir(db))
                {
                    if (db.Name.Contains("\\"))
                    {
                        foundSubDir = true;
                        break;
                    }
                }
            }

            if (foundSubDir)
            {
                dDir.ChildrenClear();
                foreach (DatBase db in arrDir)
                {
                    if (CheckDir(db))
                    {
                        if (db.Name.Contains("\\"))
                        {
                            string dirName = db.Name;
                            int    split   = dirName.IndexOf("\\", StringComparison.Ordinal);
                            string part0   = dirName.Substring(0, split);
                            string part1   = dirName.Substring(split + 1);

                            db.Name = part1;
                            DatDir dirFind = new DatDir(DatFileType.Dir)
                            {
                                Name = part0
                            };
                            if (dDir.ChildNameSearch(dirFind, out int index) != 0)
                            {
                                dDir.ChildAdd(dirFind);
                            }
                            else
                            {
                                dirFind = (DatDir)dDir.Child(index);
                            }

                            if (part1.Length > 0)
                            {
                                dirFind.ChildAdd(db);
                            }
                            continue;
                        }
                    }
                    dDir.ChildAdd(db);
                }

                arrDir = dDir.ToArray();
            }

            foreach (DatBase db in arrDir)
            {
                if (db is DatDir dbDir)
                {
                    DirectoryExpand(dbDir);
                }
            }
        }
Esempio n. 10
0
        private void writeBase(dsw sw, DatDir baseDirIn, bool newStyle)
        {
            DatBase[] dirChildren = baseDirIn.ToArray();

            if (dirChildren == null)
            {
                return;
            }
            foreach (DatBase baseObj in dirChildren)
            {
                DatDir baseDir = baseObj as DatDir;
                if (baseDir != null)
                {
                    if (baseDir.DGame != null)
                    {
                        DatGame g = baseDir.DGame;
                        sw.Write(newStyle ? @"<set" : @"<game");

                        sw.WriteItem("name", baseDir.Name);

                        if (newStyle)
                        {
                            if (baseDir.DatFileType == DatFileType.DirTorrentZip)
                            {
                                sw.WriteItem("type", "trrntzip");
                            }
                            else if (baseDir.DatFileType == DatFileType.DirRVZip)
                            {
                                sw.WriteItem("type", "rvzip");
                            }
                            else if (baseDir.DatFileType == DatFileType.Dir7Zip)
                            {
                                sw.WriteItem("type", "7zip");
                            }
                            else if (baseDir.DatFileType == DatFileType.Dir)
                            {
                                sw.WriteItem("type", "dir");
                            }
                        }

                        if (!g.IsEmuArc)
                        {
                            //         sw.WriteItem("cloneof", g.CloneOf);
                            //         sw.WriteItem("romof", g.RomOf);
                        }
                        sw.WriteEnd(@">", 1);

                        sw.WriteNode("description", g.Description);
                        if (g.IsEmuArc)
                        {
                            sw.WriteLine("<tea>", 1);
                            sw.WriteNode("titleid", g.TitleId);
                            sw.WriteNode("source", g.Source);
                            sw.WriteNode("publisher", g.Publisher);
                            sw.WriteNode("developer", g.Developer);
                            sw.WriteNode("year", g.Year);
                            sw.WriteNode("genre", g.Genre);
                            sw.WriteNode("subgenre", g.SubGenre);
                            sw.WriteNode("ratings", g.Ratings);
                            sw.WriteNode("score", g.Score);
                            sw.WriteNode("players", g.Players);
                            sw.WriteNode("enabled", g.Enabled);
                            sw.WriteNode("crc", g.CRC);
                            sw.WriteNode("cloneof", g.CloneOf);
                            sw.WriteNode("relatedto", g.RelatedTo);

                            sw.WriteLine("</trurip>", -1);
                        }
                        else
                        {
                            sw.WriteNode("year", g.Year);
                            sw.WriteNode("manufacturer", g.Manufacturer);
                        }

                        writeBase(sw, baseDir, newStyle);
                        sw.WriteLine(newStyle ? @"</set>" : @"</game>", -1);
                    }
                    else
                    {
                        sw.WriteLine(@"<dir name=""" + Etxt(baseDir.Name) + @""">", 1);
                        writeBase(sw, baseDir, newStyle);
                        sw.WriteLine(@"</dir>", -1);
                    }
                    continue;
                }

                if (baseObj is DatFile baseRom)
                {
                    if (baseRom.Name.Substring(baseRom.Name.Length - 1) == "/" && newStyle)
                    {
                        sw.Write(@"<dir");
                        sw.WriteItem("name", baseRom.Name.Substring(0, baseRom.Name.Length - 1));
                        //sw.WriteItem("merge", baseRom.Merge);
                        if (baseRom.Date != "1996/12/24 23:32:00")
                        {
                            sw.WriteItem("date", baseRom.Date);
                        }
                        sw.WriteEnd("/>");
                    }
                    else
                    {
                        sw.Write(newStyle ? @"<file" : @"<rom");
                        sw.WriteItem("name", baseRom.Name);
                        //sw.WriteItem("merge", baseRom.Merge);
                        sw.WriteItem("size", baseRom.Size);
                        sw.WriteItem("crc", baseRom.CRC);
                        sw.WriteItem("sha1", baseRom.SHA1);
                        sw.WriteItem("md5", baseRom.MD5);
                        if (baseRom.Date != "1996/12/24 23:32:00")
                        {
                            sw.WriteItem("date", baseRom.Date);
                        }
                        if (baseRom.Status != null && baseRom.Status.ToLower() != "good")
                        {
                            sw.WriteItem("status", baseRom.Status);
                        }
                        sw.WriteEnd("/>");
                    }
                }
            }
        }
Esempio n. 11
0
        public static void DatSetMakeMergeSet(DatDir tDat, bool mergeWithGameName = true)
        {
            // look for merged roms, check if a rom exists in a parent set where the Name,Size and CRC all match.

            for (int g = 0; g < tDat.ChildCount; g++)
            {
                DatDir mGame = (DatDir)tDat.Child(g);

                if (mGame.DGame == null)
                {
                    DatSetMakeMergeSet(mGame, mergeWithGameName);
                    continue;
                }

                // find all parents of this game
                List <DatDir> lstParentGames = new List <DatDir>();
                DatFindParentSets.FindParentSet(mGame, tDat, true, ref lstParentGames);

                // if no parents are found then just set all children as kept
                if (lstParentGames.Count == 0)
                {
                    for (int r = 0; r < mGame.ChildCount; r++)
                    {
                        if (mGame.Child(r) is DatFile dfGame)
                        {
                            RomCheckCollect(dfGame, false);
                        }
                    }

                    continue;
                }

                List <DatDir> pGames = new List <DatDir>();
                List <DatDir> pBios  = new List <DatDir>();
                foreach (DatDir dd in lstParentGames)
                {
                    if (dd.DGame.IsBios?.ToLower() == "yes")
                    {
                        pBios.Add(dd);
                    }
                    else
                    {
                        pGames.Add(dd);
                    }
                }

                DatBase[]      mGameTest = mGame.ToArray();
                List <DatBase> mGameKeep = new List <DatBase>();

                foreach (DatBase tGame in mGameTest)
                {
                    if (((DatFile)tGame).Status == "nodump")
                    {
                        mGame.ChildAdd(tGame);
                        continue;
                    }

                    // first remove any file that is in a parent BIOS set
                    bool found = false;
                    foreach (DatDir romofGame in pBios)
                    {
                        for (int r1 = 0; r1 < romofGame.ChildCount; r1++)
                        {
                            // size/checksum compare, so name does not need to match
                            // if (!string.Equals(mGame[r].Name, romofGame.Child(r1).Name, StringComparison.OrdinalIgnoreCase))
                            // {
                            //     continue;
                            // }

                            ulong?size0 = ((DatFile)tGame).Size;
                            ulong?size1 = ((DatFile)romofGame.Child(r1)).Size;
                            if ((size0 != null) && (size1 != null) && (size0 != size1))
                            {
                                continue;
                            }

                            byte[] crc0 = ((DatFile)tGame).CRC;
                            byte[] crc1 = ((DatFile)romofGame.Child(r1)).CRC;
                            if ((crc0 != null) && (crc1 != null) && !ArrByte.bCompare(crc0, crc1))
                            {
                                continue;
                            }

                            byte[] sha0 = ((DatFile)tGame).SHA1;
                            byte[] sha1 = ((DatFile)romofGame.Child(r1)).SHA1;
                            if ((sha0 != null) && (sha1 != null) && !ArrByte.bCompare(sha0, sha1))
                            {
                                continue;
                            }

                            byte[] md50 = ((DatFile)tGame).MD5;
                            byte[] md51 = ((DatFile)romofGame.Child(r1)).MD5;
                            if ((md50 != null) && (md51 != null) && !ArrByte.bCompare(md50, md51))
                            {
                                continue;
                            }

                            if (((DatFile)tGame).isDisk != ((DatFile)romofGame.Child(r1)).isDisk)
                            {
                                continue;
                            }

                            // not needed as we are now checking for nodumps at the top of this code
                            // don't merge if only one of the ROM is nodump
                            //if (((DatFile)romofGame.Child(r1)).Status == "nodump" != (((DatFile)mGame[r]).Status == "nodump"))
                            //{
                            //    continue;
                            //}

                            found = true;
                            break;
                        }

                        if (found)
                        {
                            break;
                        }
                    }

                    if (!found)
                    {
                        mGameKeep.Add(tGame);
                    }
                }

                mGame.ChildrenClear();

                if (pGames.Count == 0)
                {
                    foreach (DatBase tGame in mGameKeep)
                    {
                        mGame.ChildAdd(tGame);
                    }

                    continue;
                }

                DatDir romOfTopParent = pGames[pGames.Count - 1];

                foreach (DatBase tGame in mGameKeep)
                {
                    if (mergeWithGameName && !((DatFile)tGame).isDisk)
                    {
                        tGame.Name = mGame.Name + "\\" + tGame.Name;
                    }
                    romOfTopParent.ChildAdd(tGame);
                }
            }
        }
Esempio n. 12
0
        private void writeBase(dsw sw, DatDir baseDirIn)
        {
            DatBase[] dirChildren = baseDirIn.ToArray();

            if (dirChildren == null)
            {
                return;
            }
            foreach (DatBase baseObj in dirChildren)
            {
                DatDir baseDir = baseObj as DatDir;
                if (baseDir != null)
                {
                    if (baseDir.DGame != null)
                    {
                        DatGame g = baseDir.DGame;
                        sw.Write(@"<game");
                        sw.WriteItem("name", baseDir.Name);
                        if (!g.IsTea)
                        {
                            //         sw.WriteItem("cloneof", g.CloneOf);
                            //         sw.WriteItem("romof", g.RomOf);
                        }
                        sw.WriteEnd(@">", 1);

                        sw.WriteNode("description", g.Description);
                        if (g.IsTea)
                        {
                            sw.WriteLine("<tea>", 1);
                            sw.WriteNode("titleid", g.TitleId);
                            sw.WriteNode("source", g.Source);
                            sw.WriteNode("publisher", g.Publisher);
                            sw.WriteNode("developer", g.Developer);
                            sw.WriteNode("year", g.Year);
                            sw.WriteNode("genre", g.Genre);
                            sw.WriteNode("subgenre", g.SubGenre);
                            sw.WriteNode("ratings", g.Ratings);
                            sw.WriteNode("score", g.Score);
                            sw.WriteNode("players", g.Players);
                            sw.WriteNode("enabled", g.Enabled);
                            sw.WriteNode("crc", g.CRC);
                            sw.WriteNode("cloneof", g.CloneOf);
                            sw.WriteNode("relatedto", g.RelatedTo);

                            sw.WriteLine("</trurip>", -1);
                        }
                        else
                        {
                            sw.WriteNode("year", g.Year);
                            sw.WriteNode("manufacturer", g.Manufacturer);
                        }

                        writeBase(sw, baseDir);
                        sw.WriteLine(@"</game>", -1);
                    }
                    else
                    {
                        sw.WriteLine(@"<dir name=""" + Etxt(baseDir.Name) + @""">", 1);
                        writeBase(sw, baseDir);
                        sw.WriteLine(@"</dir>", -1);
                    }
                    continue;
                }
                DatFile baseRom = baseObj as DatFile;
                if (baseRom != null)
                {
                    sw.Write(@"<rom");
                    sw.WriteItem("name", baseRom.Name);
                    //sw.WriteItem("merge", baseRom.Merge);
                    sw.WriteItem("size", baseRom.Size);
                    sw.WriteItem("crc", baseRom.CRC);
                    sw.WriteItem("sha1", baseRom.SHA1);
                    sw.WriteItem("md5", baseRom.MD5);
                    if (baseRom.Status.ToLower() != "good")
                    {
                        sw.WriteItem("status", baseRom.Status);
                    }
                    sw.WriteEnd("/>");
                }
            }
        }
Esempio n. 13
0
        private static void CopyDir(DatDir datD, RvFile rvD, RvDat rvDat, HeaderFileType headerFileType, bool gameFile)
        {
            DatBase[] datB = datD.ToArray();
            if (datB == null)
            {
                return;
            }
            foreach (DatBase b in datB)
            {
                switch (b)
                {
                case DatDir nDir:
                    RvFile nd = new RvFile(ConvE(nDir.DatFileType))
                    {
                        Name      = nDir.Name + GetExt(nDir.DatFileType),
                        Dat       = rvDat,
                        DatStatus = ConvE(nDir.DatStatus)
                    };
                    if (nDir.DGame == null && !gameFile)
                    {
                        nd.Tree = new RvTreeRow();
                    }

                    rvD.ChildAdd(nd);

                    if (nDir.DGame != null)
                    {
                        DatGame dGame = nDir.DGame;
                        RvGame  cGame = new RvGame();
                        CheckAttribute(cGame, dGame.Description, RvGame.GameData.Description);
                        CheckAttribute(cGame, dGame.RomOf, RvGame.GameData.RomOf);
                        CheckAttribute(cGame, dGame.IsBios, RvGame.GameData.IsBios);
                        CheckAttribute(cGame, dGame.SourceFile, RvGame.GameData.Sourcefile);
                        CheckAttribute(cGame, dGame.CloneOf, RvGame.GameData.CloneOf);
                        CheckAttribute(cGame, dGame.SampleOf, RvGame.GameData.SampleOf);
                        CheckAttribute(cGame, dGame.Board, RvGame.GameData.Board);
                        CheckAttribute(cGame, dGame.Year, RvGame.GameData.Year);
                        CheckAttribute(cGame, dGame.Manufacturer, RvGame.GameData.Manufacturer);

                        if (nDir.DGame.IsEmuArc)
                        {
                            cGame.AddData(RvGame.GameData.EmuArc, "yes");
                            CheckAttribute(cGame, dGame.TitleId, RvGame.GameData.TitleId);
                            CheckAttribute(cGame, dGame.Publisher, RvGame.GameData.Publisher);
                            CheckAttribute(cGame, dGame.Developer, RvGame.GameData.Developer);
                            CheckAttribute(cGame, dGame.Genre, RvGame.GameData.Genre);
                            CheckAttribute(cGame, dGame.SubGenre, RvGame.GameData.SubGenre);
                            CheckAttribute(cGame, dGame.Ratings, RvGame.GameData.Ratings);
                            CheckAttribute(cGame, dGame.Score, RvGame.GameData.Score);
                            CheckAttribute(cGame, dGame.Players, RvGame.GameData.Players);
                            CheckAttribute(cGame, dGame.Enabled, RvGame.GameData.Enabled);
                            CheckAttribute(cGame, dGame.CRC, RvGame.GameData.CRC);
                            CheckAttribute(cGame, dGame.RelatedTo, RvGame.GameData.RelatedTo);
                            CheckAttribute(cGame, dGame.Source, RvGame.GameData.Source);
                        }
                        nd.Game = cGame;
                    }

                    CopyDir(nDir, nd, rvDat, headerFileType, gameFile || nDir.DGame != null);
                    break;

                case DatFile nFile:
                    RvFile nf = new RvFile(ConvE(nFile.DatFileType))
                    {
                        Name           = nFile.Name,
                        Size           = nFile.Size,
                        CRC            = nFile.CRC,
                        SHA1           = nFile.SHA1,
                        MD5            = nFile.MD5,
                        Merge          = nFile.Merge,
                        Status         = nFile.Status,
                        Dat            = rvDat,
                        DatStatus      = ConvE(nFile.DatStatus),
                        HeaderFileType = headerFileType
                    };
#if dt
                    DateTime dt;
                    if (!string.IsNullOrEmpty(nFile.DateModified) && DateTime.TryParseExact(nFile.DateModified, "yyyy/MM/dd HH:mm:ss", enUS, DateTimeStyles.None, out dt))
                    {
                        nf.DatModTimeStamp = dt.Ticks;
                    }
#endif
                    if (nFile.isDisk)
                    {
                        nf.HeaderFileType = HeaderFileType.CHD;
                    }

                    if (nf.HeaderFileType != HeaderFileType.Nothing)
                    {
                        nf.FileStatusSet(FileStatus.HeaderFileTypeFromDAT);
                    }
                    if (nf.Size != null)
                    {
                        nf.FileStatusSet(FileStatus.SizeFromDAT);
                    }
                    if (nf.CRC != null)
                    {
                        nf.FileStatusSet(FileStatus.CRCFromDAT);
                    }
                    if (nf.SHA1 != null)
                    {
                        nf.FileStatusSet(FileStatus.SHA1FromDAT);
                    }
                    if (nf.MD5 != null)
                    {
                        nf.FileStatusSet(FileStatus.MD5FromDAT);
                    }


                    rvD.ChildAdd(nf);
                    break;
                }
            }
        }
Esempio n. 14
0
        private static void CopyDir(DatDir datD, HeaderFileType headerFileType, RvDat retDat = null, RvGame retGame = null)
        {
            DatBase[] datB = datD.ToArray();
            if (datB == null)
            {
                return;
            }
            foreach (DatBase b in datB)
            {
                switch (b)
                {
                case DatDir nDir:
                    if (nDir.DGame == null)
                    {
                        break;
                    }

                    DatGame dGame = nDir.DGame;
                    RvGame  cGame = new RvGame();

                    cGame.Name         = b.Name;
                    cGame.Description  = dGame.Description;
                    cGame.Manufacturer = dGame.Manufacturer;
                    cGame.CloneOf      = dGame.CloneOf;
                    cGame.RomOf        = dGame.RomOf;
                    cGame.SampleOf     = dGame.SampleOf;
                    cGame.SourceFile   = dGame.SourceFile;
                    cGame.IsBios       = dGame.IsBios;
                    cGame.Board        = dGame.Board;
                    cGame.Year         = dGame.Year;

                    if (dGame.IsEmuArc)
                    {
                        cGame.IsTrurip  = true;
                        cGame.Publisher = dGame.Publisher;
                        cGame.Developer = dGame.Developer;
                        //cGame.Edition
                        //cGame.Version
                        //cGame.Type
                        //cGame.Media
                        //cGame.Language
                        cGame.Players = dGame.Players;
                        cGame.Ratings = dGame.Ratings;
                        cGame.Genre   = dGame.Genre;
                        //cGame.Peripheral
                        //cGame.BarCode
                        //cGame.MediaCatalogNumber
                    }
                    retDat?.AddGame(cGame);
                    CopyDir(nDir, headerFileType, null, cGame);

                    break;

                case DatFile nFile:
                    if (nFile.isDisk)
                    {
                        break;
                    }

                    RvRom nf = new RvRom()
                    {
                        Name    = nFile.Name,
                        Size    = nFile.Size,
                        CRC     = nFile.CRC,
                        SHA1    = nFile.SHA1,
                        MD5     = nFile.MD5,
                        Merge   = nFile.Merge,
                        Status  = nFile.Status,
                        AltType = headerFileType
                    };

                    retGame?.AddRom(nf);
                    break;
                }
            }
        }
Esempio n. 15
0
        private static void writeBase(DatStreamWriter sw, DatDir baseDirIn)
        {
            DatBase[] dirChildren = baseDirIn.ToArray();

            if (dirChildren == null)
            {
                return;
            }
            foreach (DatBase baseObj in dirChildren)
            {
                if (baseObj is DatDir baseDir)
                {
                    if (baseDir.DGame != null)
                    {
                        DatGame g = baseDir.DGame;
                        sw.Write(@"<machine");

                        sw.WriteItem("name", baseDir.Name);

                        if (!g.IsEmuArc)
                        {
                            sw.WriteItem("cloneof", g.CloneOf);
                            sw.WriteItem("romof", g.RomOf);
                        }
                        if (!string.IsNullOrWhiteSpace(g.IsBios) && g.IsBios != "no")
                        {
                            sw.WriteItem("isbios", g.IsBios);
                        }
                        if (!string.IsNullOrWhiteSpace(g.IsDevice) && g.IsDevice != "no")
                        {
                            sw.WriteItem("isdevice", g.IsDevice);
                        }
                        if (!string.IsNullOrWhiteSpace(g.Runnable) && g.Runnable != "yes")
                        {
                            sw.WriteItem("runnable", g.Runnable);
                        }
                        sw.WriteEnd(@">", 1);

                        sw.WriteNode("description", g.Description);
                        sw.WriteNode("year", g.Year);
                        sw.WriteNode("manufacturer", g.Manufacturer);

                        writeBase(sw, baseDir);

                        if (g.device_ref != null)
                        {
                            foreach (string d in g.device_ref)
                            {
                                sw.WriteLine($@"<device_ref name=""{d}""/>");
                            }
                        }

                        sw.WriteLine(@"</machine>", -1);
                    }
                    else
                    {
                        sw.WriteLine(@"<dir name=""" + Etxt(baseDir.Name) + @""">", 1);
                        writeBase(sw, baseDir);
                        sw.WriteLine(@"</dir>", -1);
                    }
                    continue;
                }

                if (baseObj is DatFile baseRom)
                {
                    if (baseRom.isDisk)
                    {
                        sw.Write(@"<disk");
                    }
                    else
                    {
                        sw.Write(@"<rom");
                    }

                    sw.WriteItem("name", baseRom.Name);
                    sw.WriteItem("merge", baseRom.Merge);
                    sw.WriteItem("size", baseRom.Size);
                    sw.WriteItem("crc", baseRom.CRC);
                    sw.WriteItem("sha1", baseRom.SHA1);
                    sw.WriteItem("md5", baseRom.MD5);
                    if (baseRom.DateModified != "1996/12/24 23:32:00")
                    {
                        sw.WriteItem("date", baseRom.DateModified);
                    }
                    if (baseRom.Status != null && baseRom.Status.ToLower() != "good")
                    {
                        sw.WriteItem("status", baseRom.Status);
                    }
                    sw.WriteEnd("/>");
                }
            }
        }