//private const string _path = @"D:\ext"; #endregion Fields #region Methods private static void Write() { ZzzHeader head = ZzzHeader.Read(_path, out string[] f); string path = Path.Combine(Directory.GetCurrentDirectory(), _out); Console.WriteLine(head); using (FileStream fs = File.Create(path)) { using (BinaryWriter bw = new BinaryWriter(fs)) { head.Write(bw); foreach (string file in f) { bw.Write(File.ReadAllBytes(file)); } } } Console.WriteLine($"Saved to: {path}"); try { Process.Start(Path.GetDirectoryName(path)); } catch { } }
private static void Extract() { ZzzHeader head; using (FileStream fs = File.OpenRead(_in)) { using (BinaryReader br = new BinaryReader(fs)) { head = ZzzHeader.Read(br); Console.WriteLine(head); //Directory.CreateDirectory(_path); foreach (FileData d in head.Data) { Console.WriteLine($"Writing {d}"); string path = Path.Combine(_path, d.Filename); Directory.CreateDirectory(Path.GetDirectoryName(path)); using (FileStream fso = File.Create(path)) { using (BinaryWriter bw = new BinaryWriter(fso)) { if (d.Offset <= long.MaxValue) { fs.Seek((long)d.Offset, SeekOrigin.Begin); bw.Write(br.ReadBytes((int)d.Size)); } else { throw new ArgumentOutOfRangeException($"d.offset is too large! ({d.Offset})"); } } } } } } Console.WriteLine($"Saved to: {_path}"); try { Process.Start(_path); } catch { } }