コード例 #1
0
        private void GenerateFileList_BackgroundThread(object sender, DoWorkEventArgs e)
        {
            TOCTasks.ClearEx();
            string[] extensions = { ".sfm", ".upk", ".bik", ".u", ".isb" };

            //remove trailing slash
            string      dlcCookedDir = Path.GetFullPath(e.Argument as string); //standardize
            ListBoxTask task         = new ListBoxTask($"Generating file index for {dlcCookedDir}");

            TOCTasks.Add(task);
            int rootLength = dlcCookedDir.Length + 1; //trailing slash path separator. This is used to strip off the absolute part of the path and leave only relative

            //Where first as not all files need to be selected and then filtered, they should be filtered and then selected
            var files = (Directory.EnumerateFiles(dlcCookedDir, "*.*", SearchOption.AllDirectories)
                         .Where(s => extensions.Any(ext => ext == Path.GetExtension(s).ToLower()))
                         .Select(p => p.Remove(0, rootLength))).ToList();

            string fileName = Path.Combine(dlcCookedDir, "FileIndex.txt");

            File.WriteAllLines(fileName, files);
            task.Complete($"Generated file index for {dlcCookedDir}");
            TOCTasks.Add(new ListBoxTask
            {
                Header     = "Done",
                Icon       = FontAwesomeIcon.Check,
                Foreground = Brushes.Green,
                Spinning   = false
            });
        }
コード例 #2
0
        /// <summary>
        /// Prepares to create the indexed TOC file by gathering data and then passing it to the TOC creation function
        /// </summary>
        /// <param name="consoletocFile"></param>
        public void prepareToCreateTOC(string consoletocFile)
        {
            if (!consoletocFile.EndsWith("\\"))
            {
                consoletocFile += "\\";
            }
            List <string> files = GetFiles(consoletocFile);

            if (files.Count != 0)
            {
                //These variable names.......
                ListBoxTask task = new ListBoxTask($"Creating TOC in {consoletocFile}");
                TOCTasks.Add(task);
                string t = files[0];
                int    n = t.IndexOf("DLC_");
                if (n > 0)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        files[i] = files[i].Substring(n);
                    }
                    string t2 = files[0];
                    n = t2.IndexOf("\\");
                    for (int i = 0; i < files.Count; i++)
                    {
                        files[i] = files[i].Substring(n + 1);
                    }
                }
                else
                {
                    n = t.IndexOf("BIOGame");
                    if (n > 0)
                    {
                        for (int i = 0; i < files.Count; i++)
                        {
                            files[i] = files[i].Substring(n);
                        }
                    }
                }
                string pathbase;
                string t3 = files[0];
                int    n2 = t3.IndexOf("BIOGame");
                if (n2 >= 0)
                {
                    pathbase = Path.GetDirectoryName(Path.GetDirectoryName(consoletocFile)) + "\\";
                }
                else
                {
                    pathbase = consoletocFile;
                }
                CreateTOC(pathbase, consoletocFile + "PCConsoleTOC.bin", files.ToArray());
                task.Complete($"Created TOC for {consoletocFile}");
            }
        }
コード例 #3
0
        /// <summary>
        /// Generates new items to the FileIndex.txt (ME1) removing duplicate references contained in masterList
        /// </summary>
        /// <param name="CookedPath"></param>
        /// <param name="masterList"></param>
        private void GenerateFileList(string CookedPath, List <string> masterList)
        {
            string[] extensions = { ".sfm", ".upk", ".bik", ".u", ".isb" };

            //remove trailing slash
            string      dlcCookedDir = Path.GetFullPath(CookedPath); //standardize
            ListBoxTask task         = new ListBoxTask($"Generating file index for {dlcCookedDir}");

            TOCTasks.Add(task);
            int rootLength = dlcCookedDir.Length + 1; //trailing slash path separator. This is used to strip off the absolute part of the path and leave only relative

            //Where first as not all files need to be selected and then filtered, they should be filtered and then selected
            List <string> files = (Directory.EnumerateFiles(dlcCookedDir, "*.*", SearchOption.AllDirectories)
                                   .Where(s => extensions.Any(ext => ext == Path.GetExtension(s).ToLower()))
                                   .Select(p => p.Remove(0, rootLength))).ToList();

            var addressedFiles = new List <string>();  //sub list of files that actually are addressed by the game (not duplicated at higher levels)

            foreach (string file in files)
            {
                Debug.WriteLine(file);
                if (!masterList.Contains(file))
                {
                    //Only add items that are not already done.
                    masterList.Add(file);
                    addressedFiles.Add(file);
                }
            }

            string fileName = Path.Combine(dlcCookedDir, "FileIndex.txt");

            File.WriteAllLines(fileName, addressedFiles);
            task.Complete($"Generated file index for {dlcCookedDir}");
            TOCTasks.Add(new ListBoxTask
            {
                Header     = "Done",
                Icon       = EFontAwesomeIcon.Solid_Check,
                Foreground = Brushes.Green,
                Spinning   = false
            });
        }