コード例 #1
0
            public static CompressedSectorChunk[] Read_CompressedSectorChunk(Dictionary <uint, CompressedSectorChunk> d)
            {
                uint count = 0;
                CompressedSectorChunk csc = new CompressedSectorChunk();

                CompressedSectorChunk[] result = new CompressedSectorChunk[d.Count];
                foreach (KeyValuePair <uint, cpk.CompressedSectorChunk> pair in d)
                {
                    csc           = new CompressedSectorChunk();
                    csc           = pair.Value;
                    result[count] = csc;
                    count++;
                }
                return(result);
            }
コード例 #2
0
            public static Dictionary <uint, CompressedSectorChunk> ReadSectors(Stream s)
            {
                helper help = new helper();
                CompressedSectorChunk csc = new CompressedSectorChunk();
                uint  ChunkNumber         = 0;
                ulong doffset             = 0;

                s.Seek(Header.FirstSectorPosition, 0);
                Dictionary <uint, CompressedSectorChunk> result = new Dictionary <uint, CompressedSectorChunk>();

                if (Header.MagicNumber.ToString("X8").Equals("A1B2C3D4"))
                {
                    help.ReadU16(s); help.ReadU16(s); s.Seek(help.ReadU16(s), SeekOrigin.Current);
                }
                if (Header.MagicNumber.ToString("X8").Equals("D4C3B2A1"))
                {
                    help.ReverseUInt16(help.ReadU16(s)); help.ReverseUInt16(help.ReadU16(s)); s.Seek(help.ReverseUInt16(help.ReadU16(s)), SeekOrigin.Current);
                }

                for (uint sector = 0; sector <= Header.CompSectorCount; sector++)
                {
                    uint SectorStartPosition = Header.FirstSectorPosition + sector * Header.CompSectorSize;
                    uint NextSectorPosition  = SectorStartPosition + Header.CompSectorSize;
                    s.Seek(SectorStartPosition, 0);
                    while (s.Position + 0xf < NextSectorPosition)
                    {
                        csc          = new CompressedSectorChunk();
                        csc.position = (uint)s.Position;
                        ushort Size          = help.ReadU16(s);
                        ushort flag          = help.ReadU16(s);
                        ushort CompChunkSize = help.ReadU16(s);
                        csc.nr                = ChunkNumber;
                        csc.CompChunkSize     = CompChunkSize;
                        csc.DecompChunkSize   = Size;
                        csc.flag              = flag;
                        csc.CompSector        = sector;
                        doffset              += Size;
                        csc.StartDecompOffset = doffset - Size;
                        result.Add(ChunkNumber, csc);
                        ChunkNumber++;
                        s.Seek(CompChunkSize, SeekOrigin.Current);
                    }
                }
                return(result);
            }