private async Task UpdateGameAsync(DeviceConfig deviceConfig, string platformFolderName, Game game) { // Game. string catalogGamePath = Path.Combine(deviceConfig.CatalogFolderPath, platformFolderName, game.GameFilename); if (await this.AccessProvider.IsDifferentCopyRequiredAsync(catalogGamePath, game.GameFilePath)) { NotifyProgress(this.Progress, " - Downloading " + game.GameFilename + "\n"); await this.AccessProvider.WriteAllBytesAsync(game.GameFilePath, await this.AccessProvider.ReadAllBytesAsync(catalogGamePath)); } // Game Image. string catalogGameImagePath = Path.Combine(deviceConfig.CatalogFolderPath, platformFolderName, GameList.ImagesFolderName, game.ImageFilename); if (await this.AccessProvider.IsNewerCopyRequiredAsync(catalogGameImagePath, game.ImageFilePath)) { NotifyProgress(this.Progress, " - Downloading " + game.ImageFilename + "\n"); await this.AccessProvider.WriteAllBytesAsync(game.ImageFilePath, await this.AccessProvider.ReadAllBytesAsync(catalogGameImagePath)); } }
private async Task UpdateCatalogGameListsAsync(DeviceConfig deviceConfig) { NotifyProgress(this.Progress, "Updating Catalog Game Lists\n"); foreach (string folderPath in await this.AccessProvider.GetFolderPathsAsync(deviceConfig.RomsFolderPath)) { if (this.Cancel) { break; } string platformFolderName = Path.GetDirectoryName(folderPath); var platform = GameList.GetPlatform(platformFolderName); if (platform.HasValue) { if (deviceConfig.Device.SyncPlatform(platform.Value)) { string sourcePath = GameList.GetFilePath(Path.Combine(deviceConfig.CatalogFolderPath, platformFolderName)); string destPath = GameList.GetFilePath(folderPath); if (await this.AccessProvider.IsNewerCopyRequiredAsync(sourcePath, destPath)) { NotifyProgress(this.Progress, " - Downloading " + Path.GetFileName(sourcePath) + " for " + platformFolderName + "\n"); await this.AccessProvider.CopyFileAsync(sourcePath, destPath); } } else { NotifyProgress(this.Progress, " - Removing files for " + platformFolderName + "\n"); FileSystemHelper.DeleteFolderContents(folderPath); } } } // Reload the catalog. this.Catalog = new Catalog(this.Catalog.Config); }
private async Task <List <Tuple <string, string> > > DownloadCatalogGameConfigsAsync(DeviceConfig deviceConfig, string platformFolderName) { var gameConfigs = new List <Tuple <string, string> >(); string catalogGameConfigsFolderPath = await this.AccessProvider.EnsureFolderExistsAsync( Path.Combine(deviceConfig.CatalogFolderPath, platformFolderName, GameList.GameConfigsFolderName)); foreach (string filePath in await this.AccessProvider.GetFilePathsAsync(catalogGameConfigsFolderPath)) { gameConfigs.Add(new Tuple <string, string>(Path.GetFileName(filePath), await this.AccessProvider.ReadAllTextAsync(filePath))); } return(gameConfigs); }