private void PrepareDlcIfNecessary(bool directDownload) { if (!(this.gclass30_0 is GClass32)) { return; } GClass32 gclass300 = (GClass32)this.gclass30_0; if (!gclass300.Boolean_2 || GClass3.smethod_3((GClass30)gclass300.Dlc) || gclass300.Dlc.GEnum2_0 != GEnum2.const_2 && !directDownload) { return; } try { GClass31 dlc = gclass300.Dlc; string str1 = System.IO.Path.Combine(this.DlcPath, "tmd"); string str2 = System.IO.Path.Combine(gclass300.Dlc.OutputPath, "title.tmd"); if (System.IO.Directory.Exists(this.DlcPath) && System.IO.File.Exists(str1) && System.IO.File.ReadAllBytes(str1).smethod_5(System.IO.File.ReadAllBytes(str2))) { return; } System.IO.Directory.CreateDirectory(this.DlcPath); dlc.method_16(this.DlcPath, false, directDownload, (IEnumerable <GClass12>)null, false); System.IO.File.Copy(str2, str1, true); } catch { } }
private void PrepareDlcIfNecessary(bool directDownload) { if (!(this.gclass30_0 is GClass32) || directDownload) { return; } GClass32 gclass300 = (GClass32)this.gclass30_0; if (!gclass300.Boolean_2 || GClass3.smethod_3((GClass30)gclass300.Dlc) || this.DlcIsInstalled()) { return; } gclass300.Dlc.method_2(this.DlcPath); }
private void PrepareUpdateIfNecessary(bool directDownload) { if (!(this.gclass30_0 is GClass32)) { return; } GClass32 gclass300 = (GClass32)this.gclass30_0; if (!gclass300.AreThereUpdates || GClass3.smethod_3((GClass30)gclass300.Updates[0])) { return; } bool flag = false; try { if (!System.IO.Directory.Exists(this.UpdatePath)) { System.IO.Directory.CreateDirectory(this.UpdatePath); } else { string str = System.IO.Path.Combine(this.UpdatePath, "meta", "meta.xml"); if (System.IO.File.Exists(str)) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(str); flag = xmlDocument.SelectSingleNode("/menu[@type=\"complex\"]/title_version[@type=\"unsignedInt\"]/text()").Value == gclass300.Updates.Last <GClass33>((Func <GClass33, bool>)(x => x.GEnum2_0 == GEnum2.const_2)).Version; } } if (flag) { return; } if (!directDownload) { gclass300.Updates.Last <GClass33>((Func <GClass33, bool>)(x => x.GEnum2_0 == GEnum2.const_2)).method_16(this.UpdatePath, false, false, (IEnumerable <GClass12>)null, false); } else { gclass300.Updates.Last <GClass33>().method_16(this.UpdatePath, false, true, (IEnumerable <GClass12>)null, false); } } catch { } }
private void PrepareUpdateIfNecessary(bool directDownload) { if (!(this.gclass30_0 is GClass32) || directDownload) { return; } GClass32 gclass300 = (GClass32)this.gclass30_0; if (!gclass300.Boolean_3 || GClass3.smethod_3((GClass30)gclass300.Updates[0])) { return; } bool flag = false; try { GClass33 gclass33 = gclass300.Updates.Last <GClass33>((Func <GClass33, bool>)(x => x.GEnum2_0 == GEnum2.const_2)); if (!Directory.Exists(this.UpdatePath)) { Directory.CreateDirectory(this.UpdatePath); } else if (this.UpdateIsInstalled() && System.IO.File.Exists(this.UpdateVersionFilePath)) { flag = System.IO.File.ReadAllText(this.UpdateVersionFilePath) == gclass33.Version; } if (flag || directDownload) { return; } gclass33.method_3(this.UpdatePath, false); FileSystem.RenameFile(Path.Combine(this.UpdatePath, "game.cxi"), "00000000.app"); System.IO.File.WriteAllText(this.UpdateVersionFilePath, gclass33.Version); } catch { } }
private void DownloadArchive(GClass32 archive) { string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Citra), "nand", "00000000000000000000000000000000", "title", archive.TitleId.Low.ToLower(), archive.TitleId.High.ToLower(), "content"); Directory.CreateDirectory(str); string destinationFile = Path.Combine(str, "00000000.app.romfs"); if (System.IO.File.Exists(destinationFile)) { return; } GClass80 gclass80 = new GClass80((WebProxy)null, true, true); FrmWait frmWait = new FrmWait("Downloading system archive from: NUS...", true); gclass80.Event_5 += (EventHandler <GClass81>)((_param1, _param2) => { string temp_dir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); GClass6.smethod_5(temp_dir); Directory.CreateDirectory(temp_dir); Path.Combine(temp_dir, "game.cia"); archive.method_5(temp_dir, "game"); GClass27.smethod_11(temp_dir); ProcessStartInfo processStartInfo1 = new ProcessStartInfo() { FileName = Path.Combine(temp_dir, "PART1"), WorkingDirectory = temp_dir }; Process process1 = new Process(); process1.StartInfo = processStartInfo1; process1.EnableRaisingEvents = true; process1.Exited += (EventHandler)((sender1, e1) => { try { IEnumerable <FileInfo> potential_files = new DirectoryInfo(temp_dir).EnumerateFiles("contents.*"); if (potential_files.Count <FileInfo>() == 0) { throw new Exception("An error occured while preparing the system archive!"); } FileInfo fileInfo = potential_files.First <FileInfo>((Func <FileInfo, bool>)(x => x.Length == potential_files.Max <FileInfo>((Func <FileInfo, long>)(y => y.Length)))); ProcessStartInfo processStartInfo2 = new ProcessStartInfo() { FileName = Path.Combine(temp_dir, "3dstool.exe"), WorkingDirectory = temp_dir, Arguments = string.Format("-xvtf cfa {0} --romfs 00000000.app.romfs --romfs-auto-key", (object)fileInfo) }; Process process2 = new Process(); process2.StartInfo = processStartInfo2; process2.Exited += (EventHandler)((sender2, e2) => { string path = Path.Combine(temp_dir, "00000000.app.romfs"); using (FileStream fileStream1 = System.IO.File.Create(destinationFile)) { using (FileStream fileStream2 = System.IO.File.Open(path, FileMode.Open)) { fileStream2.Seek(4096L, SeekOrigin.Begin); for (int index = 0; (long)index < fileStream2.Length - 4096L; ++index) { int num = fileStream2.ReadByte(); fileStream1.WriteByte((byte)num); } } } GClass6.smethod_5(temp_dir); frmWait.method_0(); }); process2.EnableRaisingEvents = true; process2.Start(); } catch { } }); process1.Start(); }); gclass80.Event_6 += (EventHandler <GEventArgs0>)((sender, e) => frmWait.method_2(e.GameProgress)); gclass80.method_1(((IEnumerable <GClass30>) new GClass30[1] { (GClass30)archive }).ToList <GClass30>(), 100, 10000); int num1 = (int)frmWait.ShowDialog(); }