Beispiel #1
0
        public void Write(PdbWriter writer, byte[] bytes, int data)
        {
            if (bytes == null || data == 0)
            {
                return;
            }

            int left = data;
            int used = 0;
            int rema = contentSize % writer.pageSize;

            if (rema != 0)
            {
                int todo = writer.pageSize - rema;
                if (todo > left)
                {
                    todo = left;
                }

                int lastPage = pages[pages.Length - 1];
                writer.Seek(lastPage, rema);
                writer.Write(bytes, used, todo);
                used += todo;
                left -= todo;
            }

            if (left > 0)
            {
                int count = (left + writer.pageSize - 1) / writer.pageSize;
                int page0 = writer.AllocatePages(count);

                writer.Seek(page0, 0);
                writer.Write(bytes, used, left);

                AddPages(page0, count);
            }

            contentSize += data;
        }
 internal void Write(PdbWriter writer, byte[] bytes)
 {
     Write(writer, bytes, bytes.Length);
 }
        public void Write(PdbWriter writer, byte[] bytes, int data)
        {
            if (bytes == null || data == 0) {
                return;
            }

            int left = data;
            int used = 0;
            int rema = contentSize % writer.pageSize;
            if (rema != 0) {
                int todo = writer.pageSize - rema;
                if (todo > left) {
                    todo = left;
                }

                int lastPage = pages[pages.Length - 1];
                writer.Seek(lastPage, rema);
                writer.Write(bytes, used, todo);
                used += todo;
                left -= todo;
            }

            if (left > 0) {
                int count = (left + writer.pageSize - 1) / writer.pageSize;
                int page0 = writer.AllocatePages(count);

                writer.Seek(page0, 0);
                writer.Write(bytes, used, left);

                AddPages(page0, count);
            }

            contentSize += data;
        }
Beispiel #4
0
        static void CopyFile(Stream read, PdbWriter writer)
        {
            BitAccess bits = new BitAccess(4096);

            // Read the header and directory from the old file.
            // System.Diagnostics.Debugger.Break();
            PdbFileHeader head = new PdbFileHeader(read, bits);
            PdbReader reader = new PdbReader(read, head.pageSize);
            MsfDirectory dir = new MsfDirectory(reader, head, bits);

            byte[] buffer = new byte[head.pageSize];

            // Copy the streams.
            DataStream[] streams = new DataStream [dir.streams.Length];
            for (int i = 0; i < dir.streams.Length; i++) {
                streams[i] = new DataStream();

                DataStream source = dir.streams[i];
                if (source.Length <= 0) {
                    continue;
                }

                int left = source.Length;
                int pos = 0;

                for (int page = 0; left > 0; page++) {
                    int todo = buffer.Length;
                    if (todo > left) {
                        todo = left;
                    }

                    dir.streams[i].Read(reader, pos, buffer, 0, todo);
                    streams[i].Write(writer, buffer, todo);

                    left -= todo;
                    pos += todo;
                }
            }

            writer.WriteMeta(streams, bits);
        }
Beispiel #5
0
 internal void Write(PdbWriter writer, byte[] bytes)
 {
     Write(writer, bytes, bytes.Length);
 }