private void LoadDlcs() { foreach (DlcContainer dlcContainer in _dlcContainerList) { using FileStream containerFile = File.OpenRead(dlcContainer.Path); PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage()); VirtualFileSystem.ImportTickets(pfs); foreach (DlcNca dlcNca in dlcContainer.DlcNcaList) { using var ncaFile = new UniqueRef <IFile>(); pfs.OpenFile(ref ncaFile.Ref(), dlcNca.Path.ToU8Span(), OpenMode.Read).ThrowIfFailure(); Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), dlcContainer.Path); if (nca != null) { Dlcs.Add(new DlcModel(nca.Header.TitleId.ToString("X16"), dlcContainer.Path, dlcNca.Path, dlcNca.Enabled)); } } } }
void ScanForLocalContentInternal() { var existingModFolders = GetExistingModFolders().ToArray(); var newContent = new RvContentScanner(this).ScanForNewContent(Dlcs.Select(x => x.PackageName).ToList(), existingModFolders).ToArray(); var removedContent = InstalledContent.OfType <IPackagedContent>() .Where(x => !ModExists(x, existingModFolders)) .Cast <Content>(); ProcessAddedAndRemovedContent(newContent, removedContent); }
private void RemoveDlcs(bool removeSelectedOnly = false) { if (removeSelectedOnly) { Dlcs.RemoveAll(Dlcs.Where(x => x.IsEnabled).ToList()); } else { Dlcs.Clear(); } }
private async Task AddDlc(string path) { if (!File.Exists(path) || Dlcs.FirstOrDefault(x => x.ContainerPath == path) != null) { return; } using (FileStream containerFile = File.OpenRead(path)) { PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage()); bool containsDlc = false; VirtualFileSystem.ImportTickets(pfs); foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) { using var ncaFile = new UniqueRef <IFile>(); pfs.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), path); if (nca == null) { continue; } if (nca.Header.ContentType == NcaContentType.PublicData) { if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000) != TitleId) { break; } Dlcs.Add(new DlcModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true)); containsDlc = true; } } if (!containsDlc) { await ContentDialogHelper.CreateErrorDialog(this, LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]); } } }