Example #1
0
        void ReadHeader()
        {
            byte[] header = new byte[this.headersize];
            this.fromfile.Seek(this.seekStart, System.IO.SeekOrigin.Begin);
            this.fromfile.Read(header, 0, this.headersize);
            int index = 0;

            // check prefix
            foreach (byte b in HEADERPREFIX)
            {
                if (header[index] != b)
                {
                    throw new LinkedFileException("invalid header prefix");
                }
                index++;
            }
            // skip version (for now)
            index++;
            // read buffersize
            this.buffersize   = BufferFile.Retrieve(header, index);
            index            += BufferFile.INTSTORAGE;
            this.FreeListHead = BufferFile.RetrieveLong(header, index);
            this.SanityCheck();
            this.headerDirty = false;
        }
Example #2
0
 byte[] ParseBuffer(long bufferNumber, out byte type, out long nextBufferNumber)
 {
     byte[] thebuffer  = new byte[this.buffersize];
     byte[] fullbuffer = new byte[this.buffersize + BUFFEROVERHEAD];
     this.buffers.GetBuffer(bufferNumber, fullbuffer, 0, fullbuffer.Length);
     type             = fullbuffer[0];
     nextBufferNumber = BufferFile.RetrieveLong(fullbuffer, 1);
     Array.Copy(fullbuffer, BUFFEROVERHEAD, thebuffer, 0, this.buffersize);
     return(thebuffer);
 }