Exemplo n.º 1
0
        public static List <ModFpkEntry> BuildFpk(string FpkFolder, string rootDir)
        {
            Debug.LogLine($"[BuildFpk] {FpkFolder}.");
            string FpkName        = FpkFolder.Substring(FpkFolder.LastIndexOf("\\") + 1).Replace("_fpk", ".fpk");
            string FpkBuildFolder = FpkFolder.Substring(0, FpkFolder.TrimEnd('\\').LastIndexOf("\\"));
            //string FpkXmlFile = FpkBuildFolder + "\\" + FpkName + ".xml";
            string FpkFile = FpkBuildFolder + "\\" + FpkName;
            string FpkType = FpkFolder.Substring(FpkFolder.LastIndexOf("_") + 1);

            List <string> fpkFiles = new List <string>();

            List <ModFpkEntry> fpkList = new List <ModFpkEntry>();

            foreach (string FileName in Directory.GetFiles(FpkFolder, "*.*", SearchOption.AllDirectories))
            {
                if (!GzsLib.IsExtensionValidForArchive(FileName, FpkName))
                {
                    Debug.LogLine($"[BuildFpk] {FileName} is not a valid file for a {Path.GetExtension(FpkName)} archive.");
                    continue;
                }

                string inQarName = FileName.Substring(FpkFolder.Length).Replace("\\", "/");
                fpkList.Add(new ModFpkEntry()
                {
                    FilePath    = inQarName,
                    FpkFile     = Tools.ToQarPath(FpkFile.Substring(rootDir.Length)),
                    ContentHash = Tools.GetMd5Hash(FileName)
                });
                fpkFiles.Add(inQarName);
            }

            List <string> fpkFilesSorted = GzsLib.SortFpksFiles(FpkType, fpkFiles);

            GzsLib.WriteFpkArchive(FpkFile, FpkFolder, fpkFilesSorted);

            return(fpkList);
        }