Exemple #1
0
        internal void Read(PdbReader reader, int position,
                           byte[] bytes, int offset, int data)
        {
            if (position + data > contentSize)
            {
                throw new PdbException("DataStream can't read off end of stream. " +
                                       "(pos={0},siz={1})",
                                       position, data);
            }
            if (position == contentSize)
            {
                return;
            }

            int left = data;
            int page = position / reader.pageSize;
            int rema = position % reader.pageSize;

            // First get remained of first page.
            if (rema != 0)
            {
                int todo = reader.pageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(pages[page], rema);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }

            // Now get the remaining pages.
            while (left > 0)
            {
                int todo = reader.pageSize;
                if (todo > left)
                {
                    todo = left;
                }

                reader.Seek(pages[page], 0);
                reader.Read(bytes, offset, todo);

                offset += todo;
                left   -= todo;
                page++;
            }
        }
    internal void Read(PdbReader reader, int position,
                     byte[] bytes, int offset, int data) {
      if (position + data > contentSize) {
        throw new PdbException("DataStream can't read off end of stream. " +
                                       "(pos={0},siz={1})",
                               position, data);
      }
      if (position == contentSize) {
        return;
      }

      int left = data;
      int page = position / reader.pageSize;
      int rema = position % reader.pageSize;

      // First get remained of first page.
      if (rema != 0) {
        int todo = reader.pageSize - rema;
        if (todo > left) {
          todo = left;
        }

        reader.Seek(pages[page], rema);
        reader.Read(bytes, offset, todo);

        offset += todo;
        left -= todo;
        page++;
      }

      // Now get the remaining pages.
      while (left > 0) {
        int todo = reader.pageSize;
        if (todo > left) {
          todo = left;
        }

        reader.Seek(pages[page], 0);
        reader.Read(bytes, offset, todo);

        offset += todo;
        left -= todo;
        page++;
      }
    }
        internal MsfDirectory(PdbReader reader, PdbFileHeader head, BitAccess bits)
        {
            bits.MinCapacity(head.directorySize);
            int pages = reader.PagesFromSize(head.directorySize);

            // 0..n in page of directory pages.
            reader.Seek(head.directoryRoot, 0);
            bits.FillBuffer(reader.reader, pages * 4);

            DataStream stream = new DataStream(head.directorySize, bits, pages);

            bits.MinCapacity(head.directorySize);
            stream.Read(reader, bits);

            // 0..3 in directory pages
            int count;

            bits.ReadInt32(out count);

            // 4..n
            int[] sizes = new int[count];
            bits.ReadInt32(sizes);

            // n..m
            streams = new DataStream[count];
            for (int i = 0; i < count; i++)
            {
                if (sizes[i] <= 0)
                {
                    streams[i] = new DataStream();
                }
                else
                {
                    streams[i] = new DataStream(sizes[i], bits,
                                                reader.PagesFromSize(sizes[i]));
                }
            }
        }