Пример #1
0
        protected override void DoRun(string[] args)
        {
            if (ExpandInputDirectories)
            {
                List <string> newInput = new List <string>();
                foreach (string s in Input)
                {
                    if (Path.GetExtension(s) == "")
                    {
                        newInput.AddRange(Directory.GetFiles(s, "*.flc", SearchOption.AllDirectories));
                        newInput.AddRange(Directory.GetFiles(s, "*.fl", SearchOption.AllDirectories));
                    }
                    else
                    {
                        newInput.Add(s);
                    }
                }

                Input = newInput.ToArray();
            }

            for (int i = 0; i < Input.Length; i++)
            {
                string input = Path.GetFullPath(Input[i]);
                if (!SupportedInputExtensions.Select(x => string.IsNullOrEmpty(x) ? "" : "." + x)
                    .Contains(Path.GetExtension(input)))
                {
                    throw new Exception("Extension is not supported: " + Path.GetExtension(input));
                }

                string output = Output.Length <= i
                                    ? Path.Combine(
                    Path.GetDirectoryName(input),
                    Path.GetFileNameWithoutExtension(input) +
                    "." +
                    SupportedOutputExtensions.First()
                    )
                                    : Output[i];

                FLData.SetProgress(
                    $"{Path.GetFileName(input)} => {Path.GetFileName(output)}",
                    0,
                    i + 1,
                    Input.Length
                    );
                if (!SupportedOutputExtensions.Select(x => string.IsNullOrEmpty(x) ? "" : "." + x)
                    .Contains(Path.GetExtension(output)))
                {
                    throw new Exception("Extension is not supported: " + Path.GetExtension(output));
                }

                Run(input, output);
            }
        }
Пример #2
0
        protected override void Run(string input, string output)
        {
            int    maxProgress     = 2;
            int    currentProgress = 1;
            string oldDir          = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(input);
            if (ExportFL)
            {
                string dir = Path.Combine(
                    oldDir,
                    "temp_" +
                    Path.GetFileNameWithoutExtension(Directory.GetCurrentDirectory())
                    );
                CopyDirectory(Directory.GetCurrentDirectory(), dir);
                Directory.SetCurrentDirectory(dir);
                string[] files = Directory.GetFiles(dir, "*.fl", SearchOption.AllDirectories);

                maxProgress += files.Length;
                FLData.SetProgress("Exporting FL Scripts..", 1, currentProgress, maxProgress);
                currentProgress++;
                for (int i = 0; i < files.Length; i++)
                {
                    string file = files[i];

                    FLData.SetProgress("Exporting File:" + file, 2, currentProgress, maxProgress);
                    currentProgress++;

                    SerializableFLProgram prog = Parse(file, Defines);

                    string f = file + "c";
                    Save(f, prog, ExtraSteps);

                    if (!KeepFL)
                    {
                        File.Delete(file);
                    }
                }
            }

            FLData.SetProgress("Creating Package.", 1, currentProgress, maxProgress);
            currentProgress++;

            Directory.SetCurrentDirectory(oldDir);
            ResourceManager.Create(
                input,
                output,
                PackageName,
                UnpackConfig,
                null
                );

            FLData.SetProgress("Cleaning Up.", 1, currentProgress, maxProgress);
        }