public void Cat(List <string> cmdArgs) { var predicate = GetPredicate(cmdArgs); var entry = _pack.Entries.FirstOrDefault(e => predicate(e.Name)); if (entry == null) { System.Console.Error.WriteLine($"No entry found matching"); return; } var ext = Path.GetExtension(entry.Name); if (ext == ".wimpy" || entry.Name.EndsWith("Animation.json", StringComparison.OrdinalIgnoreCase)) { var br = new BinaryReader(_pack.GetEntryStream(entry.Name)); using (var reader = new GGBinaryReader(br)) { var values = reader.ReadDirectory(); System.Console.WriteLine(values); } return; } var entryStream = _pack.GetEntryStream(entry.Name); var text = new StreamReader(entryStream).ReadToEnd(); System.Console.WriteLine(text); }
public void Extract(List <string> cmdArgs) { var predicate = GetPredicate(cmdArgs); foreach (var entry in _pack.Entries) { if (!predicate(entry.Name)) { continue; } var ext = Path.GetExtension(entry.Name); if (ext == ".wimpy" || entry.Name.EndsWith("Animation.json", StringComparison.OrdinalIgnoreCase)) { var entryStream = _pack.GetEntryStream(entry.Name); using (var reader = new GGBinaryReader(new BinaryReader(entryStream))) { var content = reader.ReadDirectory(); File.WriteAllText(entry.Name, content.ToString()); } } else { var entryStream = _pack.GetEntryStream(entry.Name); using (var fs = File.OpenWrite(GetEntryName(entry.Name))) { entryStream.CopyTo(fs); } } } }
private void OnSelectedChanged() { var entry = _pack.Entries[_listViewEntries.SelectedItem]; if (string.Equals(Path.GetExtension(entry.Name), ".png", StringComparison.OrdinalIgnoreCase)) { _detailView.Text = "no preview"; return; } if (string.Equals(Path.GetExtension(entry.Name), ".ogg", StringComparison.OrdinalIgnoreCase)) { _detailView.Text = "no preview"; return; } if (string.Equals(Path.GetExtension(entry.Name), ".wav", StringComparison.OrdinalIgnoreCase)) { _detailView.Text = "no preview"; return; } if (string.Equals(Path.GetExtension(entry.Name), ".wimpy", StringComparison.OrdinalIgnoreCase) || entry.Name.EndsWith("Animation.json", StringComparison.OrdinalIgnoreCase)) { var sr = new BinaryReader(_pack.GetEntryStream(entry.Name)); using (var reader = new GGBinaryReader(sr)) { var hash = reader.ReadDirectory(); _detailView.Text = hash.ToString(); } return; } using (var reader = new StreamReader(_pack.GetEntryStream(entry.Name))) { _detailView.Text = reader.ReadToEnd(); } }