Esempio n. 1
0
        public override bool Execute(List <string> args)
        {
            if (args.Count != 1 && args.Count != 2)
            {
                return(false);
            }
            var virtualPath = args[0];
            var outputPath  = (args.Count == 2) ? args[1] : virtualPath;
            var file        = _list.Find(virtualPath);

            if (file == null)
            {
                Console.Error.WriteLine("Unable to find file {0}.", virtualPath);
                return(true);
            }
            var outDir = Path.GetDirectoryName(outputPath);

            if (!string.IsNullOrEmpty(outDir))
            {
                Directory.CreateDirectory(outDir);
            }
            var data = _list.Extract(file);

            File.WriteAllBytes(outputPath, data);
            Console.WriteLine("Wrote 0x{0:X} bytes to {1}.", data.Length, outputPath);
            return(true);
        }
Esempio n. 2
0
        public override bool Execute(List <string> args)
        {
            if (args.Count != 1 && args.Count != 2)
            {
                return(false);
            }
            var virtualPath = args[0];
            var inputPath   = (args.Count == 2) ? args[1] : virtualPath;
            var file        = _list.Find(virtualPath);

            if (file == null)
            {
                Console.Error.WriteLine("Unable to find file {0}.", virtualPath);
                return(true);
            }
            byte[] data;
            try
            {
                data = File.ReadAllBytes(inputPath);
            }
            catch (IOException)
            {
                Console.Error.WriteLine("Unable to read from {0}.", inputPath);
                return(true);
            }
            _list.Replace(file, data);
            using (var stream = _fileInfo.Open(FileMode.Open, FileAccess.ReadWrite))
                TagSerializer.Serialize(new TagSerializationContext(stream, _cache, _tag), _list);
            Console.WriteLine("Imported 0x{0:X} bytes.", data.Length);
            return(true);
        }