public RomData Clone() { RomData data = new RomData() { Background = this.Background, Banner = this.Banner, BoxArt = this.BoxArt, Description = this.Description, Developer = this.Developer, FriendlyName = this.FriendlyName, Logo = this.Logo, NumPlayers = this.NumPlayers, Path = this.Path, Publisher = this.Publisher, Rating = this.Rating, ReleaseDate = this.ReleaseDate, TimePlayed = this.TimePlayed, IsUpToDate = this.IsUpToDate, Console = this.Console, ScrapedBy = this.ScrapedBy, ScraperUniqueKey = this.ScraperUniqueKey }; return(data); }
public void UpdateRomData(RomData data) { if (loadedRomData.ContainsKey(data.Path)) { loadedRomData[data.Path] = data; } else { loadedRomData.TryAdd(data.Path, data); } String relativePathToConfig = Path.Combine("Games", data.Console.FriendlyName, String.Format("{0}.data.json", Path.GetFileNameWithoutExtension(data.Path))); FileUtilities.WriteFile(data, relativePathToConfig, imageConverter, consoleConverter); }
public List <RomData> GetRoms(EmulatorConsoles ConsoleToSearch) { List <RomData> returnList = new List <RomData>(); String pathToSearch = Path.Combine(rootDirectory, ConsoleToSearch.FriendlyName); List <String> acceptableExtensions = ConsoleToSearch.FileExtensions; foreach (var file in Directory.EnumerateFiles(pathToSearch)) { String fileExtension = Path.GetExtension(file); if (acceptableExtensions.Contains(fileExtension)) { RomData data = RetrieveRomData(file, ConsoleToSearch); returnList.Add(data); } } return(returnList); }
private RomData RetrieveRomData(String file, EmulatorConsoles ConsoleToSearch) { String pathToConfig = Path.Combine(FileUtilities.GetRootDirectory(), "Games", ConsoleToSearch.FriendlyName, String.Format("{0}.data.json", Path.GetFileNameWithoutExtension(file))); if (loadedRomData.ContainsKey(file)) { return(loadedRomData[file]); } else if (File.Exists(pathToConfig)) { RomData loadedData = FileUtilities.LoadFile <RomData>(pathToConfig, imageConverter, consoleConverter); loadedRomData.TryAdd(loadedData.Path, loadedData); return(loadedData); } else { return(new RomData() { Path = file, FriendlyName = Path.GetFileName(file), Console = ConsoleToSearch, IsUpToDate = false, NumPlayers = "Unknown", Description = "No Description", Developer = "Unknown", Publisher = "Unknown", Rating = 0.0f, BoxArt = Resource.DefaultBoxart, Logo = Resource.DefaultIcon, Banner = Resource.DefaultBanner, Background = Resource.DefaultBackground }); } }
private void NewRomFound(object sender, FileSystemEventArgs e) { RomData romData = RetrieveRomData(e.FullPath, ((RomFileSystemWatcher)sender).associatedConsole); NewRomAdded?.Invoke(romData); }