Example #1
0
        public BundleExtraction(string single_bundle, bool list, CheckedListBox.CheckedItemCollection list_info, string list_formatter)
        {
            this.list          = list;
            this.single_bundle = single_bundle;

            if (String.IsNullOrWhiteSpace(StaticStorage.settings.CustomExtractPath))
            {
                if (!Directory.Exists(Path.Combine(StaticStorage.settings.AssetsFolder, "extract")))
                {
                    Directory.CreateDirectory(Path.Combine(StaticStorage.settings.AssetsFolder, "extract"));
                }

                extract_folder = Path.Combine(StaticStorage.settings.AssetsFolder, "extract");
            }
            else
            {
                extract_folder = StaticStorage.settings.CustomExtractPath;
            }

            if (list)
            {
                Type output_type;
                switch (list_formatter)
                {
                case "CSV":
                    output_type = typeof(CSVListOutputter);
                    break;

                default:
                    output_type = typeof(ListOutputter);
                    break;
                }

                ListOutput = (ListOutputter)Activator.CreateInstance(output_type, !String.IsNullOrWhiteSpace(StaticStorage.settings.ListLogFile) ? StaticStorage.settings.ListLogFile : "./listlog.log", new ListOptions(list_info), this);
            }
        }
Example #2
0
        public void Start()
        {
            List <string> files;

            if (single_bundle != null)
            {
                files = new List <string> {
                    Path.Combine(StaticStorage.settings.AssetsFolder, single_bundle)
                }
            }
            ;
            else
            {
                files = Directory.EnumerateFiles(StaticStorage.settings.AssetsFolder, "*.bundle").ToList();
            }

            total_bundle = (uint)files.Count();

            foreach (string file in files)
            {
                if (this.terminate)
                {
                    break;
                }

                if (file.EndsWith("_h.bundle"))
                {
                    continue;
                }

                PackageHeader bundle;
                string        bundle_path = file.Replace(".bundle", "");
                string        bundle_id   = Path.GetFileName(bundle_path);

                bundle = new PackageHeader();
                TextWriteLine("Loading bundle header " + bundle_id);
                if (!bundle.Load(file))
                {
                    TextWriteLine("Failed to parse bundle header.");
                    continue;
                }
                if (bundle.Entries.Count == 0)
                {
                    continue;
                }

                current_bundle_name           = bundle_id;
                current_bundle_progress       = 0;
                current_bundle_total_progress = list && this.ListOutput.ListOptions.EntryInfo.Count == 0 ? 1 : bundle.Entries.Count;
                if (list)
                {
                    ListBundle(bundle, bundle_id);
                }
                else
                {
                    TextWriteLine("Extracting bundle: " + bundle_id);
                    ExtractBundle(bundle, bundle_id);
                }
                current_bundle++;
            }
            if (ListOutput != null)
            {
                TextWriteLine("Writing List information to file");
                ListOutput.Write();
                ListOutput = null;
            }
            Finished = true;
        }