Beispiel #1
0
        public override void Execute(ScriptState state)
        {
            string path = state.ResolvePath(File);

            state.Log.Status($"Exporting to {path}");
            FileTypeInfo fti = ForceType;

            if (ForceType == null)
            {
                var ext = System.IO.Path.GetExtension(path);
                if (!FileTypeInfo.TryParseName(ext, out fti))
                {
                    throw new Exception($"Unrecognised file extension \"{ext}\". Use a conventional extension or specify the type explicitly.");
                }
            }

            if (!fti.CanExport)
            {
                throw new Exception($"Cannot export {fti.FormatName}");
            }

            fti.Export(state.Data, path);
        }