Exemplo n.º 1
0
        public override bool Execute(List <string> args)
        {
            if (args.Count != 2 && args.Count != 3)
            {
                return(false);
            }
            var tag = ArgumentParser.ParseTagIndex(_cache, args[0]);

            if (tag == null)
            {
                return(false);
            }
            var file = args[1];
            var full = false;

            if (args.Count == 3)
            {
                if (args[2] == "full")
                {
                    full = true;
                }
                else
                {
                    return(false);
                }
            }

            byte[] data;
            using (var stream = _fileInfo.OpenRead())
                data = full ? _cache.ExtractTagWithHeader(stream, tag) : _cache.ExtractTag(stream, tag);
            using (var outStream = File.Open(file, FileMode.Create, FileAccess.Write))
            {
                outStream.Write(data, 0, data.Length);
                Console.WriteLine("Wrote 0x{0:X} bytes to {1}.", outStream.Position, file);
                Console.WriteLine("The tag's main struct will be at offset 0x{0:X}.", tag.MainStructOffset);
            }
            return(true);
        }