private void ProcessDownload(object state) { try { string source = System.IO.Path.Combine(Sys.Settings.LibraryLocation, "temp", File); _dest = System.IO.Path.Combine(Sys.Settings.LibraryLocation, File); byte[] sig = new byte[4]; using (var iro = new _7thWrapperLib.IrosArc(source, true)) { if (!iro.CheckValid()) { throw new Exception("IRO archive appears to be invalid: corrupted download?"); } if (!Controller.WaitForPatches()) { throw new Exception("Failed to acquire patches"); } int numPatch = Controller.PatchFiles.Count; int pDone = 0; foreach (string pfile in Controller.PatchFiles) { string patchfile = System.IO.Path.Combine(Sys.Settings.LibraryLocation, "temp", pfile); using (var patch = new _7thWrapperLib.IrosArc(patchfile)) { iro.ApplyPatch(patch, (d, _) => SetPCComplete((int)((100 / numPatch) * pDone + 100 * d / numPatch))); } pDone++; } } System.IO.File.Move(source, _dest); } catch (Exception e) { Error(e); return; } SetPCComplete(100); Complete(); }
private void ProcessDownload(object state) { string patchfile = System.IO.Path.Combine(Sys.Settings.LibraryLocation, "temp", File); try { string source = System.IO.Path.Combine(Sys.Settings.LibraryLocation, Install.LatestInstalled.InstalledLocation); using (var iro = new _7thWrapperLib.IrosArc(source, true)) { using (var patch = new _7thWrapperLib.IrosArc(patchfile)) { iro.ApplyPatch(patch, (d, _) => SetPCComplete((int)(100 * d))); } } } catch (Exception e) { Error(e); return; } Sys.Library.QueuePendingDelete(new[] { patchfile }); SetPCComplete(100); Complete(); }
private void ProcessDownload(object state) { string patchfile = Path.Combine(Sys.Settings.LibraryLocation, "temp", Filename); try { if (Install == null) { Install = Sys.Library.GetItem(Mod.ID); if (Install == null) { // don't go any further since mod is not installed Error(new Exception($"{Mod.Name} not installed")); return; } } string source = Path.Combine(Sys.Settings.LibraryLocation, Install.LatestInstalled.InstalledLocation); using (var iro = new _7thWrapperLib.IrosArc(source, true)) { using (var patch = new _7thWrapperLib.IrosArc(patchfile)) { iro.ApplyPatch(patch, (d, msg) => { Sys.Message(new WMessage(msg, WMessageLogLevel.LogOnly)); SetPercentComplete((int)(100 * d)); }); } } File.Delete(patchfile); } catch (Exception e) { Error(e); return; } SetPercentComplete(100); Complete(); }
static void Main(string[] args) { if (args.Length == 0) { System.Console.WriteLine(HELP); return; } _7thWrapperLib.RuntimeLog.Enabled = args.Any(s => s.Equals("/LOG", StringComparison.InvariantCultureIgnoreCase)); Action <double, string> onProgress = (d, s) => { Console.WriteLine(String.Format("{0}%: {1}", (int)(d * 100), s)); }; if (args[0].Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { _7thWrapperLib.IrosArc iro = new _7thWrapperLib.IrosArc(args[1]); foreach (string s in iro.GetInformation()) { Console.WriteLine(s); } } else if (args[0].Equals("CREATE", StringComparison.InvariantCultureIgnoreCase)) { List <_7thWrapperLib.IrosArc.ArchiveCreateEntry> entries = new List <_7thWrapperLib.IrosArc.ArchiveCreateEntry>(); string dir = args[2]; foreach (string file in System.IO.Directory.GetFiles(dir, "*", System.IO.SearchOption.AllDirectories)) { entries.Add(_7thWrapperLib.IrosArc.ArchiveCreateEntry.FromDisk(dir, file.Substring(dir.Length).Trim('/', '\\'))); } _7thWrapperLib.CompressType compress = (_7thWrapperLib.CompressType)Enum.Parse(typeof(_7thWrapperLib.CompressType), args[3]); using (var fs = new System.IO.FileStream(args[1], System.IO.FileMode.Create)) _7thWrapperLib.IrosArc.Create(fs, entries, _7thWrapperLib.ArchiveFlags.None, compress, onProgress ); } else if (args[0].Equals("EXTRACT", StringComparison.InvariantCultureIgnoreCase)) { _7thWrapperLib.IrosArc iro = new _7thWrapperLib.IrosArc(args[1]); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); string filter = args.Length > 3 ? args[3] : String.Empty; foreach (string file in iro.AllFileNames()) { if (!String.IsNullOrEmpty(filter) && (file.IndexOf(filter) < 0)) { continue; } Console.WriteLine("Writing " + file); byte[] data = iro.GetBytes(file); string fn = System.IO.Path.Combine(args[2], file); fn = fn.Replace("%", "___").Replace(":", "---"); System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn)); System.IO.File.WriteAllBytes(fn, data); } sw.Stop(); Console.WriteLine("Done in " + (sw.ElapsedMilliseconds / 1000f) + " seconds"); } else if (args[0].Equals("MAKEPATCH", StringComparison.InvariantCultureIgnoreCase)) { _7thWrapperLib.IrosArc orig = new _7thWrapperLib.IrosArc(args[1]); _7thWrapperLib.IrosArc newarc = new _7thWrapperLib.IrosArc(args[2]); _7thWrapperLib.CompressType compress = (_7thWrapperLib.CompressType)Enum.Parse(typeof(_7thWrapperLib.CompressType), args[4]); using (var fs = new System.IO.FileStream(args[3], System.IO.FileMode.Create)) { _7thWrapperLib.IrosPatcher.Create(orig, newarc, fs, compress, onProgress); } } else if (args[0].Equals("APPLYPATCH", StringComparison.InvariantCultureIgnoreCase)) { _7thWrapperLib.IrosArc orig = new _7thWrapperLib.IrosArc(args[1], true); _7thWrapperLib.IrosArc patch = new _7thWrapperLib.IrosArc(args[2]); orig.ApplyPatch(patch, onProgress); } }