示例#1
0
        /// <summary>
        /// Replace the file content with a new content,
        /// and write the modified bundle to the GGPK.
        /// </summary>
        /// <returns>Size of imported bytes</returns>
        public virtual void ReplaceContent(byte[] NewContent)
        {
            var BundleToSave = ggpkContainer.Index.GetSmallestBundle();

            BundleFileRecord.Write(NewContent);
            if (BundleFileRecord.bundleRecord != BundleToSave)
            {
                BundleFileRecord.Move(BundleToSave);
            }
            var NewBundleData = BundleToSave.Save(ggpkContainer.Reader, ggpkContainer.RecordOfBundle[BundleToSave].DataBegin);
            var fr            = ggpkContainer.RecordOfBundle[BundleToSave];

            fr.ReplaceContent(NewBundleData);
            BundleToSave.Bundle.offset = fr.DataBegin;
            UpdateCache(BundleToSave);
            ggpkContainer.IndexRecord.ReplaceContent(ggpkContainer.Index.Save());
        }
示例#2
0
 /// <summary>
 /// Replace the file content with a new content,
 /// and return the bundle which have to be saved.
 /// </summary>
 /// <returns>Size of imported bytes</returns>
 public virtual int BatchReplaceContent(byte[] NewContent, BundleRecord BundleToSave)
 {
     BundleFileRecord.Write(NewContent);
     LastFileToUpdate = this;
     if (BundleFileRecord.bundleRecord != BundleToSave)
     {
         BundleFileRecord.Move(BundleToSave);
     }
     return(NewContent.Length);
 }