예제 #1
0
        public void Save(Stream output, IList <IArchiveFileInfo> files)
        {
            // Prepare stream
            var archiveOffset = GetArchiveOffset(_header.type);
            var archiveSize   = files[0].FileSize;

            var hfsLength = HfsStream.GetBaseLength(archiveSize);

            output.SetLength(archiveOffset + hfsLength);

            using var bw = new BinaryWriterX(output, ByteOrder.BigEndian);

            // Write HFS content
            var hfsStream = new HfsStream(new SubStream(output, archiveOffset, hfsLength));

            (files[0] as ArchiveFileInfo).SaveFileData(hfsStream);

            hfsStream.Flush();

            // Write header
            _header.fileSize = (int)archiveSize;

            bw.BaseStream.Position = 0;
            bw.WriteType(_header);
        }