예제 #1
0
        private static bool TryGetGame(string romName, string mameFolder, DateTime versionAllowed, out Hiscore game)
        {
            game = null;
            List<Hiscore> validGames = new List<Hiscore>();

            for (int i = 0; i < m_games.Length; i++)
            {
                string[] gamesSupported = m_games[i].GamesSupported;

                for (int j = 0; j < gamesSupported.Length; j++)
                {
                    if (gamesSupported[j] == romName)
                        validGames.Add(m_games[i]);
                }
            }

            DateTime oldestValid = DateTime.Now;
            foreach (Hiscore gm in validGames)
            {
                if ((gm.GetVersionDate.CompareTo(oldestValid) <= 0 && 
                    gm.GetVersionDate.CompareTo(versionAllowed) >= 0) ||
                    gm.GetVersionDate.Equals(DateTime.MaxValue))
                {
                    game = gm;
                    oldestValid = gm.GetVersionDate;
                }
            }

            if (game != null)
            {
                game.FileNames = GetFileNamesFromGame(mameFolder, romName, game);
                return true;
            }

            return false;
        }
예제 #2
0
        private static string[] GetFileNamesFromGame(string mameFolder, string romName, Hiscore game)
        {
            List<string> possibleFileNames = GetPossibleFileNames(mameFolder, romName);

            string[] extReq = game.ExtensionsRequired;
            string[] fileNameArray = new String[extReq.Length];
            for (int x = 0; x < extReq.Length; x++)
            {
                foreach (string pfn in possibleFileNames)
                {
                    if (extReq[x].Equals(Path.GetExtension(pfn)))
                    {
                        if (File.Exists(pfn))
                            fileNameArray[x] = pfn;
                        else
                            fileNameArray[x] = romName + extReq[x];

                        break;
                    }
                }
            }

            return fileNameArray;
        }