예제 #1
0
파일: ChunkData.cs 프로젝트: aeo24/WoWMap
        public ChunkData(Stream stream, uint chunkSize = 0)
        {            
            Stream = stream;
            Chunks = new List<Chunk>();

            var maxRead = (uint)stream.Position + chunkSize;
            if (chunkSize == 0)
                maxRead = (uint)stream.Length;
            maxRead = Math.Min(maxRead, (uint)stream.Length);

            var br = new BinaryReader(stream);
            var baseOffset = (uint)stream.Position;
            var calcOffset = 0u;
            while ((calcOffset + baseOffset) < maxRead && (calcOffset < maxRead))
            {
                var header = new ChunkHeader(br);
                calcOffset += 8; // Add 8 bytes as we read header name + size
                Chunks.Add(new Chunk(header.Name, header.Size, calcOffset + baseOffset, stream));
                calcOffset += header.Size; // Move past the chunk

                // We seek from our current position to save some time
                if ((calcOffset + baseOffset) < maxRead && calcOffset < maxRead)
                    stream.Seek(header.Size, SeekOrigin.Current);
            }
        }
예제 #2
0
파일: Chunk.cs 프로젝트: WowDevs/WoWMap
 public Chunk(ChunkHeader header, Stream stream)
     : this(header.Name, header.Size, (uint)stream.Position, stream)
 {
 }
예제 #3
0
파일: Chunk.cs 프로젝트: aeo24/WoWMap
 public Chunk(ChunkHeader header, Stream stream)
     : this(header.Name, header.Size, (uint)stream.Position, stream)
 { }