void readHeader() throws Exception { byte[] header = new byte[this.headersize]; // this.fromfile.Seek(this.seekStart, System.IO.SeekOrigin.Begin); this.fromfile.seek(this.seekStart); // this.fromfile.Read(header, 0, this.headersize); this.fromfile.read(header, 0, this.headersize); int index = 0; // check prefix // foreach (byte b in HEADERPREFIX) for (int i = 0; i < HEADERPREFIX.length; i++) { byte b = HEADERPREFIX[i]; 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; }
public ParseBuffer(long bufferNumber) throws Exception { byte[] thebuffer = new byte[LinkedFile.this.buffersize]; byte[] fullbuffer = new byte[LinkedFile.this.buffersize + LinkedFile.BUFFEROVERHEAD]; LinkedFile.this.buffers.getBuffer(bufferNumber, fullbuffer, 0, fullbuffer.length); this.type = fullbuffer[0]; this.NextBufferNumber = BufferFile.RetrieveLong(fullbuffer, 1); for (int i = 0; i < LinkedFile.this.buffersize; i++) { thebuffer[i] = fullbuffer[i + LinkedFile.BUFFEROVERHEAD]; } this.payload = thebuffer; }