public synchronized void writeBytes(long index, byte[] buffer, int offset, int length)
			throws IOException {
		if (accessMode != AccessMode.WRITE) {
			throw new IOException("Not write mode");
		}

		doWriteBytes(index, buffer, offset, length);
		long writeEnd = index + length;
		currentLength = Math.max(currentLength, writeEnd);

		// after writing new bytes to the file, update
		// any buffers that we can completely fill with the contents of
		// this write buffer, and invalidate any buffers that we can't
		// completely fill (they can be re-read in a normal fashion later when needed)
		while (length > 0) {
			long bufferPos = getBufferPos(index);
			int bufferOfs = (int) (index - bufferPos);
			int bytesAvailForThisBuffer = Math.min(length, BUFFER_SIZE - bufferOfs);

			Buffer fileBuffer = buffers.get(bufferPos);
			if (fileBuffer != null) {
				if (bufferOfs == 0 && length >= BUFFER_SIZE) {
					System.arraycopy(buffer, offset, fileBuffer.bytes, 0, BUFFER_SIZE);
					fileBuffer.len = BUFFER_SIZE;
				}
				else {
					buffers.remove(bufferPos);
					lruBuffers.remove(bufferPos);
				}
			}
			index += bytesAvailForThisBuffer;
			offset += bytesAvailForThisBuffer;
			length -= bytesAvailForThisBuffer;
		}
	}
Writes bytes to the specified offset in the file.

@param index the location in the file to starting writing
@param buffer bytes to write
@param offset offset in the buffer byte array to start 
@param length number of bytes to write
@throws IOException if bad {@link AccessMode} or other io error
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/FileByteProvider.java