GP-669: Fixing GhidraDev exception when ~/ghidra_scripts doesn't exist

This commit is contained in:
Ryan Kurtz 2021-02-08 13:02:32 -05:00
parent fef756c967
commit d9283b0b9d
5 changed files with 12 additions and 3 deletions

View file

@ -25,6 +25,7 @@ import org.eclipse.jdt.core.*;
import ghidra.GhidraApplicationLayout;
import ghidra.framework.GModule;
import ghidradev.Activator;
/**
* Utility methods for working with Ghidra scripts in Eclipse.
@ -87,6 +88,12 @@ public class GhidraScriptUtils {
// Link in the user's personal ghidra_scripts directory
if (linkUserScripts) {
if (!userScriptsDir.isDirectory()) {
if (!userScriptsDir.mkdirs()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
IStatus.ERROR, "Failed to create " + userScriptsDir, null));
}
}
IFolder link = javaProject.getProject().getFolder("Home scripts");
link.createLink(new Path(userScriptsDir.getAbsolutePath()), IResource.NONE, monitor);
classpathEntries.add(JavaCore.newSourceEntry(link.getFullPath()));