Ejemplo n.º 1
0
        public static RegionFile_Chunk GetChunkByLocation(RegionFile_Location location, Stream st)
        {
            RegionFile_Chunk tempChunk = new RegionFile_Chunk();

            BinaryReader br = new BinaryReader(st);
            {
                br.ReadBytes(8192);
                long ichi = br.BaseStream.Position;
                br.BaseStream.Position = location.offset * 4096;
                byte[]       chunkData   = br.ReadBytes(location.sectorCount * 4096);
                BinaryReader chunkDataBR = new BinaryReader(new MemoryStream(chunkData));
                tempChunk.length          = BinaryJava.ReadInt(chunkDataBR);
                tempChunk.compressionType = chunkDataBR.ReadByte();
                if (tempChunk.compressionType == 2)
                {
                    //tempChunk.Data = Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)); // chunkData.Skip(5).Take(tempChunk.length).ToArray());
                    //File.WriteAllBytes( "decomBytesNewnewnew",Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)));
                    tempChunk.tag = RegionFile_Chunk.ReadTags(Deflactor.DeCompress(chunkDataBR.ReadBytes(tempChunk.length)));
                    chunkDataBR.Dispose();
                    return(tempChunk);
                }
                else
                {
                    throw new Exception("Unknown compression type");
                }
            }
        }
Ejemplo n.º 2
0
 private void button4_Click(object sender, EventArgs e)
 {
     a = RegionFile_Chunk.ReadTags(File.ReadAllBytes(textBox1.Text));
     treeView1.Nodes.Add(AddToTree(a));
 }