public void saveAsPackedFile(Program program, File file, boolean overWrite)
			throws InvalidNameException, IOException {

		if (program == null) {
			throw new IllegalArgumentException("Program is null!");
		}
		int id = -1;
		Integer intID = openPrograms.get(program);
		if (intID != null) {
			id = intID.intValue();
		}
		if (id >= 0) {
			program.endTransaction(id, true);
		}
		boolean success = false;
		try {
			if (file.exists()) {
				if (overWrite) {
					if (!file.delete()) {
						throw new IOException("Failed to overwrite existing project file: " + file);
					}
				}
				else {
					throw new DuplicateFileException("File already exists: " + file);
				}
			}
			program.saveToPackedFile(file, TaskMonitor.DUMMY);
		}
		catch (CancelledException e1) {
			throw new IOException("Cancelled");
		}
		finally {
			if (success || id >= 0) {
				openPrograms.put(program, Integer.valueOf(program.startTransaction("")));
			}
		}
	}
Saves the given program to as a packed file.

@param program
           the program to be saved
@param file
           the packed file destination.
@param overWrite
           if true, any existing program with that name will be
           over-written.
@throws InvalidNameException
            the name is null or has invalid characters.
@throws IOException
            if there was a problem accessing the program
Ghidra/Features/Base/src/main/java/ghidra/base/project/GhidraProject.java