Пример #1
0
        public static void Repack(string sourceDir, string targetDir)
        {
            BXF4        bxf = new BXF4();
            XmlDocument xml = new XmlDocument();

            xml.Load($"{sourceDir}\\_yabber-bxf4.xml");

            string bhdFilename = xml.SelectSingleNode("bxf4/bhd_filename").InnerText;
            string bdtFilename = xml.SelectSingleNode("bxf4/bdt_filename").InnerText;

            bxf.Version      = xml.SelectSingleNode("bxf4/version").InnerText;
            bxf.Format       = (Binder.Format)Enum.Parse(typeof(Binder.Format), xml.SelectSingleNode("bxf4/format").InnerText);
            bxf.BigEndian    = bool.Parse(xml.SelectSingleNode("bxf4/bigendian").InnerText);
            bxf.BitBigEndian = bool.Parse(xml.SelectSingleNode("bxf4/bitbigendian").InnerText);
            bxf.Unicode      = bool.Parse(xml.SelectSingleNode("bxf4/unicode").InnerText);
            bxf.Extended     = Convert.ToByte(xml.SelectSingleNode("bxf4/extended").InnerText, 16);
            bxf.Unk04        = bool.Parse(xml.SelectSingleNode("bxf4/unk04").InnerText);
            bxf.Unk05        = bool.Parse(xml.SelectSingleNode("bxf4/unk05").InnerText);

            YBinder.ReadBinderFiles(bxf, xml.SelectSingleNode("bxf4/files"), sourceDir);

            string bhdPath = $"{targetDir}\\{bhdFilename}";

            YBUtil.Backup(bhdPath);
            string bdtPath = $"{targetDir}\\{bdtFilename}";

            YBUtil.Backup(bdtPath);
            bxf.Write(bhdPath, bdtPath);
        }
Пример #2
0
        public static void Repack(string sourceDir, string targetDir)
        {
            BXF4        bxf = new BXF4();
            XmlDocument xml = new XmlDocument();

            xml.Load($"{sourceDir}\\_yabber-bxf4.xml");

            string bhdFilename = xml.SelectSingleNode("bxf4/bhd/filename").InnerText;

            bxf.BHD.Timestamp = xml.SelectSingleNode("bxf4/bhd/timestamp").InnerText;
            bxf.BHD.Format    = (Binder.Format)Convert.ToByte(xml.SelectSingleNode("bxf4/bhd/format").InnerText, 16);
            bxf.BHD.Unicode   = bool.Parse(xml.SelectSingleNode("bxf4/bhd/unicode").InnerText);
            bxf.BHD.BigEndian = bool.Parse(xml.SelectSingleNode("bxf4/bhd/bigendian").InnerText);
            bxf.BHD.Flag1     = bool.Parse(xml.SelectSingleNode("bxf4/bhd/flag1").InnerText);
            bxf.BHD.Flag2     = bool.Parse(xml.SelectSingleNode("bxf4/bhd/flag2").InnerText);
            bxf.BHD.Extended  = Convert.ToByte(xml.SelectSingleNode("bxf4/bhd/extended").InnerText, 16);

            string bdtFilename = xml.SelectSingleNode("bxf4/bdt/filename").InnerText;

            bxf.BDT.Timestamp = xml.SelectSingleNode("bxf4/bdt/timestamp").InnerText;
            bxf.BDT.BigEndian = bool.Parse(xml.SelectSingleNode("bxf4/bdt/bigendian").InnerText);
            bxf.BDT.Flag1     = bool.Parse(xml.SelectSingleNode("bxf4/bdt/flag1").InnerText);
            bxf.BDT.Flag2     = bool.Parse(xml.SelectSingleNode("bxf4/bdt/flag2").InnerText);
            bxf.BDT.Unk1      = Convert.ToInt64(xml.SelectSingleNode("bxf4/bdt/unk1").InnerText, 16);

            foreach (XmlNode fileNode in xml.SelectNodes("bxf4/files/file"))
            {
                int    id    = int.Parse(fileNode.SelectSingleNode("id").InnerText);
                string root  = fileNode.SelectSingleNode("root").InnerText;
                string path  = fileNode.SelectSingleNode("path").InnerText;
                byte   flags = Convert.ToByte(fileNode.SelectSingleNode("flags").InnerText, 16);

                byte[] bytes = File.ReadAllBytes($"{sourceDir}\\{path}");
                bxf.Files.Add(new BXF4.File(id, root + path, (Binder.FileFlags)flags, bytes));
            }

            string bhdPath = $"{targetDir}\\{bhdFilename}";

            if (File.Exists(bhdPath) && !File.Exists(bhdPath + ".bak"))
            {
                File.Move(bhdPath, bhdPath + ".bak");
            }

            string bdtPath = $"{targetDir}\\{bdtFilename}";

            if (File.Exists(bdtPath) && !File.Exists(bdtPath + ".bak"))
            {
                File.Move(bdtPath, bdtPath + ".bak");
            }

            bxf.Write(bhdPath, bdtPath);
        }