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

		if (readOnly) {
			throw new IOException("File is read-only");
		}
		if (raf == null) {
			throw new ClosedException();
		}

		if (index > MAX_BUFFER_INDEX) {
			throw new EOFException("Buffer index too large, exceeds max-int");
		}

		byte[] data = buf.data;
		boolean empty = buf.isEmpty();
		if (!empty && data.length != bufferSize) {
			throw new IllegalArgumentException("Bad buffer size");
		}

		seekBufferBlock(index);

		// Write block
		if (empty) {
			raf.writeByte(EMPTY_BUFFER); // Empty flag only
			raf.writeInt(buf.getId()); // ID
		}
		else {
			raf.writeByte(0); // Clear Flags
			raf.writeInt(buf.getId()); // ID

			// Write data
			raf.write(data, 0, bufferSize);
		}

		if (index >= bufferCount) {
			// we must assume that any buffers starting with bufferCount upto index will
			// be accounted for in the ultimate free-list maintained outside the buffer file.
			bufferCount = index + 1;
		}
	}
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