private void doSetSourceFile(BufferFile newFile) {

		// Close buffer file
		if (sourceFile != null) {
			sourceFile.dispose();
			sourceFile = null;
		}

		// Switch buffer manager to use new buffer file
		int tempMaxCheckpoints = this.maxCheckpoints;
		setMaxUndos(0); // pack all versions into baseline checkpoint
		currentCheckpointHead = null; // force checkpoint on next update
		setMaxUndos(tempMaxCheckpoints); // restore max checkpoint count

		// Set all baseline nodes as unmodified
		BufferNode node = baselineCheckpointHead.nextInCheckpoint;
		while (node.id != TAIL) {
			node.modified = false;
			node.checkpoint = 0;
			node = node.nextInCheckpoint;
		}
		currentCheckpoint = 0;
		hasNonUndoableChanges = false;
		sourceFile = newFile;

		if (recoveryMgr != null) {
			recoveryMgr.clear();
		}
	}
Write all changes to the specified outFile
@param outFile output buffer file
@param monitor task monitor
@throws IOException if IO error occurs
@throws CancelledException thrown if task cancelled
Ghidra/Framework/DB/src/main/java/db/buffers/BufferMgr.java