public void saveAs(Program program, String folderPath, String name, 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 {
			DomainFolder folder = projectData.getFolder(folderPath);
			try {
				if (folder == null) {
					throw new IOException("folder not found: " + folderPath);
				}
				if (overWrite) {
					DomainFile df = folder.getFile(name);
					if (df != null) {
						df.delete();
					}
				}
				folder.createFile(name, program, MONITOR);
				success = true;
			}
			catch (DuplicateFileException e) {
				if (overWrite) {
					throw new IOException("Failed to overwrite existing project file: " + name);
				}
				throw e;
			}
		}
		catch (CancelledException e1) {
			throw new IOException("Cancelled");
		}
		finally {
			if (success || id >= 0) {
				openPrograms.put(program, Integer.valueOf(program.startTransaction("")));
			}
		}

	}
Saves the given program to the project with the given name.

@param program
           the program to be saved
@param folderPath
           the path where to save the program.
@param name
           the name to save the program as.
@param overWrite
           if true, any existing program with that name will be
           over-written.
@throws DuplicateFileException
            if a file exists with that name and overwrite is false or overwrite failed
@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