mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Extensions installed through the GUI now get put in the user settings
directory (rather than installation directory)
This commit is contained in:
parent
3ea1c2bb2b
commit
d70c6c256f
11 changed files with 116 additions and 80 deletions
|
@ -62,7 +62,7 @@ public class GhidraApplicationLayout extends ApplicationLayout {
|
|||
getApplicationInstallationDir());
|
||||
|
||||
// Extensions
|
||||
extensionInstallationDir = findExtensionInstallationDirectory();
|
||||
extensionInstallationDirs = findExtensionInstallationDirectories();
|
||||
extensionArchiveDir = findExtensionArchiveDirectory();
|
||||
|
||||
// Patch directory
|
||||
|
@ -217,17 +217,20 @@ public class GhidraApplicationLayout extends ApplicationLayout {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the directory where all Ghidra extension archives should be
|
||||
* installed. This should be at the following location:<br>
|
||||
* Returns a prioritized list of directories where Ghidra extensions are installed. These
|
||||
* should be at the following locations:<br>
|
||||
* <ul>
|
||||
* <li><code>[user settings dir]/Extensions</code></li>
|
||||
* <li><code>[application install dir]/Ghidra/Extensions</code></li>
|
||||
* <li><code>ghidra/Ghidra/Extensions</code> (development mode)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return the install folder, or null if can't be determined
|
||||
*/
|
||||
protected ResourceFile findExtensionInstallationDirectory() {
|
||||
protected List<ResourceFile> findExtensionInstallationDirectories() {
|
||||
|
||||
List<ResourceFile> dirs = new ArrayList<>();
|
||||
|
||||
// Would like to find a better way to do this, but for the moment this seems the
|
||||
// only solution. We want to get the 'Extensions' directory in ghidra, but there's
|
||||
// no way to retrieve that directory directly. We can only get the full set of
|
||||
|
@ -237,13 +240,14 @@ public class GhidraApplicationLayout extends ApplicationLayout {
|
|||
ResourceFile rootDir = getApplicationRootDirs().iterator().next();
|
||||
File temp = new File(rootDir.getFile(false), "Extensions");
|
||||
if (temp.exists()) {
|
||||
return new ResourceFile(temp);
|
||||
dirs.add(new ResourceFile(temp));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
dirs.add(new ResourceFile(new File(userSettingsDir, "Extensions")));
|
||||
dirs.add(new ResourceFile(applicationInstallationDir, "Ghidra/Extensions"));
|
||||
}
|
||||
|
||||
ResourceFile installDir = findGhidraApplicationInstallationDir();
|
||||
return new ResourceFile(installDir, "Ghidra/Extensions");
|
||||
return dirs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ public class GhidraJarApplicationLayout extends GhidraApplicationLayout {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ResourceFile findExtensionInstallationDirectory() {
|
||||
protected List<ResourceFile> findExtensionInstallationDirectories() {
|
||||
ResourceFile extensionInstallDir = new ResourceFile(
|
||||
ApplicationLayout.class.getResource("/_Root/Ghidra/Extensions").toExternalForm());
|
||||
return extensionInstallDir;
|
||||
return List.of(extensionInstallDir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
package ghidra;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
|
||||
|
@ -51,9 +52,9 @@ public class GhidraTestApplicationLayout extends GhidraApplicationLayout {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ResourceFile findExtensionInstallationDirectory() {
|
||||
protected List<ResourceFile> findExtensionInstallationDirectories() {
|
||||
File installDir = new File(getUserTempDir(), "ExtensionInstallDir");
|
||||
return new ResourceFile(installDir);
|
||||
return List.of(new ResourceFile(installDir));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,8 +17,7 @@ package utility.application;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.framework.ApplicationProperties;
|
||||
|
@ -44,7 +43,7 @@ public abstract class ApplicationLayout {
|
|||
protected File userSettingsDir;
|
||||
protected ResourceFile patchDir;
|
||||
protected ResourceFile extensionArchiveDir;
|
||||
protected ResourceFile extensionInstallationDir;
|
||||
protected List<ResourceFile> extensionInstallationDirs;
|
||||
|
||||
/**
|
||||
* Gets the application properties from the application layout
|
||||
|
@ -121,13 +120,13 @@ public abstract class ApplicationLayout {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the application Extensions installation folder.
|
||||
* Returns an {@link List ordered list} of the application Extensions installation directories.
|
||||
*
|
||||
* @return the application Extensions installation directory. Could be null if the
|
||||
* {@link ApplicationLayout} does not support application Extensions.
|
||||
* @return an {@link List ordered list} of the application Extensions installation directories.
|
||||
* Could be empty if the {@link ApplicationLayout} does not support application Extensions.
|
||||
*/
|
||||
public final ResourceFile getExtensionInstallationDir() {
|
||||
return extensionInstallationDir;
|
||||
public final List<ResourceFile> getExtensionInstallationDirs() {
|
||||
return extensionInstallationDirs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue