private void RemoveGames(DeviceConfig deviceConfig, GameList gameList)
        {
            var gameFileExtensions = GameList.GetPlatformFileExtensions(gameList.Platform);

            FileSystemHelper.EnsureFolderExists(gameList.ImagesFolderPath);

            foreach (string deviceFilePath in Directory.GetFiles(gameList.PlatformFolderPath))
            {
                if (this.Cancel)
                {
                    break;
                }

                string filename      = Path.GetFileName(deviceFilePath);
                string fileExtension = Path.GetExtension(filename).ToLower();
                if (gameFileExtensions.Contains(fileExtension))
                {
                    if (!gameList.Contains(filename) && (gameList.Platform != Platform.NeoGeo && filename != "neogeo.zip"))
                    {
                        NotifyProgress(this.Progress, " - Removing " + filename + "\n");
                        base.DeleteGameFiles(gameList.PlatformFolderPath, gameList.ImagesFolderPath, filename);
                    }
                }
            }
        }
        private async Task ProcessDeviceFilesAsync(string devicePlatformPath, string deviceImageFolderPath, GameList gameList)
        {
            var gameFileExtensions      = GameList.GetPlatformFileExtensions(gameList.Platform);
            var saveStateFileExtensions = Catalog.GetSaveStateFileExtensions();

            foreach (string deviceFilePath in await this.AccessProvider.GetFilePathsAsync(devicePlatformPath))
            {
                if (this.Cancel)
                {
                    break;
                }

                string filename      = Path.GetFileName(deviceFilePath);
                string fileExtension = Path.GetExtension(filename).ToLower();
                if (gameFileExtensions.Contains(fileExtension))
                {
                    if (!gameList.Contains(filename) && (gameList.Platform != Platform.NeoGeo && filename != "neogeo.zip"))
                    {
                        NotifyProgress(this.Progress, " - Removing " + filename + "\n");
                        base.DeleteGameFiles(devicePlatformPath, deviceImageFolderPath, filename);
                    }
                }
                else if (saveStateFileExtensions.Contains(fileExtension))
                {
                    string localPath = Path.Combine(gameList.PlatformFolderPath, GameList.SaveStatesFolderName, filename);
                    if (!await this.AccessProvider.FileExistsAsync(localPath) || await this.AccessProvider.IsNewerCopyRequiredAsync(deviceFilePath, localPath))
                    {
                        await this.AccessProvider.CopyFileAsync(deviceFilePath, localPath);
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Sets the join command.
 /// </summary>
 /// <param name="gameName">Name of the game.</param>
 public void SetJoinCommand(string gameName)
 {
     UpdateAvailableGames();
     if (GameList.Contains(gameName))
     {
         CommandToSend = "join " + gameName;
     }
 }
Beispiel #4
0
        public void ListTest()
        {
            var simplelist = new List<object>();

            object item1 = new object();
            object item2 = new object();
            object item3 = new object();
            object item4NotContains = new object();

            simplelist.Add(item1);
            simplelist.Add(item2);
            simplelist.Add(item3);

            var gameList = new GameList<object>();

            foreach (object o in simplelist)
            {
                gameList.Add(o);
            }

            foreach (object o in gameList)
            {
                Assert.IsTrue(simplelist.Contains(o));
            }

            foreach (object o in simplelist)
            {
                Assert.IsTrue(gameList.Contains(o));
            }

            Assert.IsFalse(gameList.Contains(item4NotContains));
            Assert.AreEqual(gameList.Count, 3);

            gameList.Remove(x => ReferenceEquals(x, item2));
            Assert.IsFalse(gameList.Contains(item2));
            Assert.AreEqual(gameList.Count, 2);

            gameList.Clear();
            Assert.AreEqual(gameList.Count, 0);
        }