@Override
	public synchronized DataBuffer get(DataBuffer buf, int index) throws IOException {

		if (index > bufferCount) {
			throw new EOFException("Buffer index too large (" + index + " > " + bufferCount + ")");
		}
		if (raf == null) {
			throw new ClosedException();
		}

		seekBufferBlock(index);

		// Read version 1 buffer prefix
		byte flags = raf.readByte();

		// Read buffer ID
		buf.setId(raf.readInt());

		if ((flags & EMPTY_BUFFER) != 0) {
			buf.setEmpty(true);
			buf.setId(-1);
		}
		else {
			buf.setEmpty(false);
			byte[] data = buf.data;
			if (data == null) {
				data = new byte[bufferSize];
				buf.data = data;
			}
			else if (data.length != bufferSize) {
				throw new IllegalArgumentException("Bad buffer size");
			}
			// Non-empty Buffer - read data
			raf.readFully(data);
		}
		buf.setDirty(false);
		return buf;
	}
Generate a BufferFileBlock instance which corresponds to the specified DataBuffer
based upon LocalBufferFile block usage.  This should generally not be used for writing
empty blocks since they will not be properly linked which is normally handled during
header flush which is performed by BufferFile close on files being written.
@param buf the data buffer to be converted
@param bufferSize data buffer size used for integrity check and generating empty buffer
@return BufferFileBlock instance.
Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java