private int OnExecute(IConsole console)
        {
            var reporter = new ConsoleReporter(console);

            try
            {
                if (OutputPath == null)
                {
                    OutputPath = Environment.CurrentDirectory;
                }

                if (FileHelper.IsNarc(InputPath))
                {
                    NarcArchive.ExtractTppk(InputPath, OutputPath);
                }
                else
                {
                    TppkArchive.Extract(InputPath, OutputPath);
                }

                return(0);
            }
            catch (Exception e)
            {
                reporter.Error(e.Message);

                return(e.HResult);
            }
        }
Example #2
0
        private int OnExecute(IConsole console)
        {
            var reporter = new ConsoleReporter(console);

            try
            {
                var files = new List <string>();
                foreach (var file in InputPaths)
                {
                    if (Directory.Exists(file))
                    {
                        // This is a directory, add all the DDS files in it
                        files.AddRange(Directory.EnumerateFiles(file, "*.dds"));
                    }
                    else
                    {
                        // This is a file (or has wildcards), add all the files that match it
                        var directory = Path.GetDirectoryName(file);
                        if (directory == string.Empty)
                        {
                            directory = Environment.CurrentDirectory;
                        }
                        files.AddRange(Directory.EnumerateFiles(directory, Path.GetFileName(file)));
                    }
                }

                if (File.Exists(OutputPath) && FileHelper.IsNarc(OutputPath))
                {
                    NarcArchive.UpdateTppk(files, OutputPath);
                }
                else
                {
                    TppkArchive.Create(files, OutputPath);
                }

                return(0);
            }
            catch (Exception e)
            {
                reporter.Error(e.Message);

                return(e.HResult);
            }
        }