private boolean processFileWithImport(FSRL fsrl, String folderPath) {

		Msg.info(this, "IMPORTING: " + fsrl);

		LoadResults<Program> loadResults = null;
		Loaded<Program> primary = null;
		try {

			// Perform the load.  Note that loading 1 file may result in more than 1 thing getting
			// loaded.
			loadResults = loadPrograms(fsrl, folderPath);
			Msg.info(this, "IMPORTING: Loaded " + (loadResults.size() - 1) + " additional files");

			primary = loadResults.getPrimary();
			Program primaryProgram = primary.getDomainObject();

			// Make sure we are allowed to save ALL programs to the project.  If not, save none and
			// fail.
			if (!options.readOnly) {
				for (Loaded<Program> loaded : loadResults) {
					if (!checkOverwrite(loaded)) {
						return false;
					}
				}
			}

			// Check if there are defined memory blocks in the primary program.
			// Abort if not (there is nothing to work with!).
			if (primaryProgram.getMemory().getAllInitializedAddressSet().isEmpty()) {
				Msg.error(this, "REPORT: Error: No memory blocks were defined for file " + fsrl);
				return false;
			}

			// Analyze the primary program, and determine if we should save.
			// TODO: Analyze non-primary programs (GP-2965).
			boolean doSave = analyzeProgram(fsrl.toString(), primaryProgram) && !options.readOnly;

			// The act of marking the program as temporary by a script will signal
			// us to discard any changes
			if (!doSave) {
				loadResults.forEach(e -> e.getDomainObject().setTemporary(true));
			}

			// Apply saveDomainFolder to the primary program, if applicable.
			// We don't support changing the save folder on any non-primary loaded programs.
			// Note that saveDomainFolder is set by pre/post-scripts, so it can only be used
			// after analysis happens.
			if (saveDomainFolder != null) {
				primary.setProjectFolderPath(saveDomainFolder.getPathname());
				if (!checkOverwrite(primary)) {
					return false;
				}
			}

			// Save
			for (Loaded<Program> loaded : loadResults) {
				if (!loaded.getDomainObject().isTemporary()) {
					try {
						DomainFile domainFile =
							loaded.save(project, new MessageLog(), TaskMonitor.DUMMY);
						Msg.info(this, String.format("REPORT: Save succeeded for: %s (%s)", loaded,
							domainFile));
					}
					catch (IOException e) {
						Msg.info(this, "REPORT: Save failed for: " + loaded);
					}
				}
				else {
					if (options.readOnly) {
						Msg.info(this,
							"REPORT: Discarded file import due to readOnly option: " + loaded);
					}
					else {
						Msg.info(this, "REPORT: Discarded file import as a result of script " +
							"activity or analysis timeout: " + loaded);
					}
				}
			}

			// Commit changes
			if (options.commit) {
				for (Loaded<Program> loaded : loadResults) {
					if (!loaded.getDomainObject().isTemporary()) {
						if (loaded == primary) {
							AutoAnalysisManager.getAnalysisManager(primaryProgram).dispose();
						}
						loaded.release(this);
						commitProgram(loaded.getSavedDomainFile());
					}
				}
			}

			Msg.info(this, "REPORT: Import succeeded");
			return true;
		}
		catch (LoadException e) {
			Msg.error(this, "The AutoImporter could not successfully load " + fsrl +
				" with the provided import parameters. Please ensure that any specified" +
				" processor/cspec arguments are compatible with the loader that is used during" +
				" import and try again.");
			if (options.loaderClass != null && options.loaderClass != BinaryLoader.class) {
				Msg.error(this,
					"NOTE: Import failure may be due to missing opinion for \"" +
						options.loaderClass.getSimpleName() +
						"\". If so, please contact Ghidra team for assistance.");
			}
			return false;
		}
		catch (Exception e) {
			Msg.error(this, "REPORT: " + e.getMessage(), e);
			return false;
		}
		finally {
			if (loadResults != null) {
				loadResults.release(this);
			}
		}
	}
Process the specified filename within parentFolder.
@param parentFolder domain folder to be searched
@param filename name of file to be imported
@return true if one or more files processed
@throws IOException if an IO problem occurred.
Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessAnalyzer.java