Exemple #1
0
        private void ImportNewFile(RpkgBinaryWriter writer, RpkgEntry rpkgEntry)
        {
            var rawData = rpkgEntry.ImportRawData ?? File.ReadAllBytes(rpkgEntry.Import);

            if (rpkgEntry.IsCompressed)
            {
                rpkgEntry.CompressedSize = writer.WriteCompressedBytes(rawData);
            }
            else
            {
                writer.Write(rawData);
            }
        }
Exemple #2
0
        public void SaveOriginalRpkgFileStructure(RpkgBinaryWriter writer)
        {
            writer.Write(Archive);

            for (int i = 0; i < Archive.NumberOfFiles; i++)
            {
                writer.Write(Archive.Entries[i]);
            }

            for (int i = 0; i < Archive.NumberOfFiles; i++)
            {
                writer.Write(Archive.Entries[i].Info);
            }
        }
Exemple #3
0
        public void SaveDataEntry(RpkgBinaryReader reader, RpkgBinaryWriter writer, RpkgEntry rpkgEntry)
        {
            long originalOffset = (long)rpkgEntry.Offset;

            rpkgEntry.Offset = (ulong)writer.BaseStream.Position;

            if (rpkgEntry.Import != null)
            {
                ImportNewFile(writer, rpkgEntry);
            }
            else
            {
                if (reader.BaseStream.Position != originalOffset)
                {
                    reader.BaseStream.Seek(originalOffset, SeekOrigin.Begin);
                }
                int size = rpkgEntry.IsCompressed ? (int)rpkgEntry.CompressedSize : (int)rpkgEntry.Info.DecompressedDataSize;
                writer.Write(reader.ReadBytes(size));
            }
        }
Exemple #4
0
 public void AppendDataEntry(RpkgBinaryWriter writer, RpkgEntry rpkgEntry)
 {
     writer.BaseStream.Seek(0, SeekOrigin.End);
     rpkgEntry.Offset = (ulong)writer.BaseStream.Position;
     ImportNewFile(writer, rpkgEntry);
 }
Exemple #5
0
 public void UpdateSavedRpkgFileStructure(RpkgBinaryWriter writer)
 {
     writer.BaseStream.Seek(0, SeekOrigin.Begin);
     SaveOriginalRpkgFileStructure(writer);
 }