Ejemplo n.º 1
0
        /// <summary>
        /// writes the index data and the raw file blocks to the destination stream.
        /// </summary>
        /// <param name="destStream"></param>
        /// <param name="idx"></param>
        /// <param name="dataArray"></param>
        /// <param name="updIndex"></param>
        public static void AddRawData(Stream destStream, RawIndex idx, byte[] dataArray, IndexHandler updIndex)
        {
            // serialize and compress the index data:
            byte[] indexData = RawIndex.ToByteArray(idx);

            // generate the header bytes:
            byte[] header = BitConverter.GetBytes((ushort)indexData.Length);

            // move to the end of the stream:
            destStream.Position = destStream.Length;

            // write the header data:
            destStream.Write(header, 0, header.Length);

            // write the index data:
            destStream.Write(indexData, 0, indexData.Length);

            // add the index record to the handler:
            updIndex.ArchiveIndex.Add(new ArchiveFileIndex()
            {
                FileLength     = idx.L,
                FileName       = idx.N,
                FileStartIndex = destStream.Position
            });

            // write the data to the stream
            destStream.Write(dataArray, 0, dataArray.Length);
        }