Example #1
0
        private static void ExtractWilay(Options options)
        {
            if (options.Input == null && options.ArdFilename == null)
            {
                throw new NullReferenceException("Input was not specified.");
            }
            if (options.Output == null)
            {
                throw new NullReferenceException("Output directory was not specified.");
            }

            if (options.ArdFilename != null)
            {
                string input = options.Input ?? "/menu/image/";
                using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
                {
                    Extract.ExtractTextures(archive, input, options.Output, options.Progress);
                }
            }
            else
            {
                if (File.Exists(options.Input))
                {
                    Extract.ExtractTextures(new[] { options.Input }, options.Output, options.Progress);
                }

                if (Directory.Exists(options.Input))
                {
                    string   pattern   = options.Filter ?? "*";
                    string[] filenames = Directory.GetFiles(options.Input, pattern);
                    Extract.ExtractTextures(filenames, options.Output, options.Progress);
                }
            }
        }
Example #2
0
        private static void ExtractArchive(Options options)
        {
            if (options.ArdFilename == null)
            {
                throw new NullReferenceException("Archive must be specified");
            }

            using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
            {
                FileArchive.Extract(archive, options.Output, options.Progress);
            }
        }
Example #3
0
        public static void Extract(FileArchive archive, string outDir)
        {
            foreach (FileInfo fileInfo in archive.FileInfo.Where(x => !string.IsNullOrWhiteSpace(x.Filename)))
            {
                string filename = Path.Combine(outDir, fileInfo.Filename.TrimStart('/'));
                string dir      = Path.GetDirectoryName(filename) ?? throw new InvalidOperationException();
                Directory.CreateDirectory(dir);

                using (var outStream = new FileStream(filename, FileMode.Create, FileAccess.Write))
                {
                    archive.OutputFile(fileInfo, outStream);
                }
            }
        }
Example #4
0
        private static BdatTables ReadBdatTables(Options options, bool readMetadata)
        {
            if (options.Game == Game.XB2 && options.ArdFilename != null)
            {
                using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
                {
                    return(new BdatTables(archive, readMetadata));
                }
            }

            string pattern = options.Filter ?? "*";

            string[] filenames = Directory.GetFiles(options.BdatDir, pattern);
            return(new BdatTables(filenames, options.Game, readMetadata));
        }
Example #5
0
        private static void ReadGimmick(Options options)
        {
            using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
            {
                if (options.ArdFilename == null)
                {
                    throw new NullReferenceException("Archive must be specified");
                }
                if (options.Output == null)
                {
                    throw new NullReferenceException("No output file was specified.");
                }

                BdatCollection tables = GetBdatCollection(options);

                var gimmicks = ReadGmk.ReadAll(archive, tables);
                ExportMap.ExportCsv(gimmicks, options.Output);

                ExportMap.Export(archive, gimmicks, options.Output);
            }
        }
Example #6
0
        private static void ReplaceArchive(Options options)
        {
            if (options.ArdFilename == null)
            {
                throw new NullReferenceException("Archive must be specified");
            }
            if (options.Input == null)
            {
                throw new NullReferenceException("No input file was specified.");
            }
            if (options.Output == null)
            {
                throw new NullReferenceException("No output file was specified.");
            }

            using (var archive = new FileArchive(options.ArhFilename, options.ArdFilename))
            {
                byte[] replacement = File.ReadAllBytes(options.Input);
                archive.ReplaceFile(options.Output, replacement);
            }
        }