Beispiel #1
0
 public void Serialize(SerializingFile con, HeaderStruct header)
 {
     Header   = header;
     MyOffset = (uint)con.GetPos();
     if (con.isLoading)
     {
         Hash = new byte[16];
     }
     for (int i = 0; i < 16; i++)
     {
         Hash[i] = con + Hash[i];
     }
     BlockSizeIndex        = con + BlockSizeIndex;
     UncompressedSize      = con + UncompressedSize;
     UncompressedSizeAdder = con + UncompressedSizeAdder;
     RealUncompressedSize  = UncompressedSize + UncompressedSizeAdder << 32;
     DataOffset            = con + DataOffset;
     DataOffsetAdder       = con + DataOffsetAdder;
     RealDataOffset        = DataOffset + DataOffsetAdder << 32;
     if (BlockSizeIndex == 0xFFFFFFFF)
     {
         BlockOffsets     = new long[1];
         BlockOffsets[0]  = RealDataOffset;
         BlockSizes       = new ushort[1];
         BlockSizes[0]    = (ushort)UncompressedSize;
         BlockTableOffset = 0;
     }
     else
     {
         int numBlocks = (int)Math.Ceiling((double)UncompressedSize / (double)header.MaxBlockSize);
         if (con.isLoading)
         {
             BlockOffsets = new long[numBlocks];
             BlockSizes   = new ushort[numBlocks];
         }
         BlockOffsets[0] = RealDataOffset;
         long pos = con.Memory.Position;
         con.Seek((int)getBlockOffset((int)BlockSizeIndex, header.EntryOffset, header.FileCount), SeekOrigin.Begin);
         BlockTableOffset = con.Memory.Position;
         BlockSizes[0]    = con + BlockSizes[0];
         for (int i = 1; i < numBlocks; i++)
         {
             BlockSizes[i]   = con + BlockSizes[i];
             BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i];
         }
         con.Seek((int)pos, SeekOrigin.Begin);
     }
 }
Beispiel #2
0
 public void Serialize(SerializingFile con)
 {
     if (con.isLoading)
     {
         Header = new HeaderStruct();
     }
     Header.Serialize(con);
     con.Seek((int)Header.EntryOffset, SeekOrigin.Begin);
     if (con.isLoading)
     {
         Files = new FileEntryStruct[Header.FileCount];
     }
     for (int i = 0; i < Header.FileCount; i++)
     {
         Files[i].Serialize(con, Header);
     }
     if (con.isLoading)
     {
         ReadFileNames(con);
     }
 }
Beispiel #3
0
 public void Serialize(SerializingFile con, HeaderStruct header)
 {
     Header = header;
     MyOffset = (uint)con.GetPos();
     if (con.isLoading)
         Hash = new byte[16];
     for (int i = 0; i < 16; i++)
         Hash[i] = con + Hash[i];
     BlockSizeIndex = con + BlockSizeIndex;
     UncompressedSize = con + UncompressedSize;
     UncompressedSizeAdder = con + UncompressedSizeAdder;
     RealUncompressedSize = UncompressedSize + UncompressedSizeAdder << 32;
     DataOffset = con + DataOffset;
     DataOffsetAdder = con + DataOffsetAdder;
     RealDataOffset = DataOffset + DataOffsetAdder << 32;
     if (BlockSizeIndex == 0xFFFFFFFF)
     {
         BlockOffsets = new long[1];
         BlockOffsets[0] = RealDataOffset;
         BlockSizes = new ushort[1];
         BlockSizes[0] = (ushort)UncompressedSize;
         BlockTableOffset = 0;
     }
     else
     {
         int numBlocks = (int)Math.Ceiling((double)UncompressedSize / (double)header.MaxBlockSize);
         if (con.isLoading)
         {
             BlockOffsets = new long[numBlocks];
             BlockSizes = new ushort[numBlocks];
         }
         BlockOffsets[0] = RealDataOffset;
         long pos = con.Memory.Position;
         con.Seek((int)getBlockOffset((int)BlockSizeIndex, header.EntryOffset, header.FileCount), SeekOrigin.Begin);
         BlockTableOffset = con.Memory.Position;
         BlockSizes[0] = con + BlockSizes[0];
         for (int i = 1; i < numBlocks; i++)
         {
             BlockSizes[i] = con + BlockSizes[i];
             BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i];
         }
         con.Seek((int)pos, SeekOrigin.Begin);
     }
 }
Beispiel #4
0
 public void Serialize(SerializingFile con)
 {
     if (con.isLoading)
         Header = new HeaderStruct();
     Header.Serialize(con);
     con.Seek((int)Header.EntryOffset, SeekOrigin.Begin);
     if (con.isLoading)
         Files = new FileEntryStruct[Header.FileCount];
     for (int i = 0; i < Header.FileCount; i++)
         Files[i].Serialize(con, Header);
     if (con.isLoading)
         ReadFileNames(con);
 }