mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-0: Using SequencedCollection for application root dirs since order
matters
This commit is contained in:
parent
2e7c5da7b0
commit
ea076b3fa6
5 changed files with 22 additions and 26 deletions
|
@ -87,7 +87,7 @@ public class GenericApplicationLayout extends ApplicationLayout {
|
|||
* @param applicationProperties The properties object that will be read system properties.
|
||||
* @throws IOException if there was a problem getting a user directory.
|
||||
*/
|
||||
public GenericApplicationLayout(Collection<ResourceFile> applicationRootDirs,
|
||||
public GenericApplicationLayout(SequencedCollection<ResourceFile> applicationRootDirs,
|
||||
ApplicationProperties applicationProperties) throws IOException {
|
||||
|
||||
this.applicationProperties = Objects.requireNonNull(applicationProperties);
|
||||
|
@ -179,9 +179,9 @@ public class GenericApplicationLayout extends ApplicationLayout {
|
|||
* first entry will be the primary root in both cases.
|
||||
* @return root directories
|
||||
*/
|
||||
public static Collection<ResourceFile> getDefaultApplicationRootDirs() {
|
||||
public static SequencedCollection<ResourceFile> getDefaultApplicationRootDirs() {
|
||||
|
||||
Set<ResourceFile> results = new HashSet<>();
|
||||
List<ResourceFile> results = new ArrayList<>();
|
||||
String additionalRootsProperty = System.getProperty(ADDITIONAL_APPLICATION_ROOT_DIRS);
|
||||
if (!StringUtils.isBlank(additionalRootsProperty)) {
|
||||
String[] paths = additionalRootsProperty.split(File.pathSeparator);
|
||||
|
|
|
@ -113,9 +113,9 @@ public class GhidraApplicationLayout extends ApplicationLayout {
|
|||
/**
|
||||
* Finds the application root directories for this application layout.
|
||||
*
|
||||
* @return A collection of the application root directories for this layout.
|
||||
* @return A {@link SequencedCollection} of the application root directories for this layout.
|
||||
*/
|
||||
protected Collection<ResourceFile> findGhidraApplicationRootDirs() {
|
||||
protected SequencedCollection<ResourceFile> findGhidraApplicationRootDirs() {
|
||||
return ApplicationUtilities.findDefaultApplicationRootDirs();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -48,17 +48,14 @@ public class GhidraJarApplicationLayout extends GhidraApplicationLayout {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ResourceFile> findGhidraApplicationRootDirs() {
|
||||
List<ResourceFile> dirs = new ArrayList<>();
|
||||
protected SequencedCollection<ResourceFile> findGhidraApplicationRootDirs() {
|
||||
String appPropPath = "/_Root/Ghidra/" + ApplicationProperties.PROPERTY_FILE;
|
||||
URL appPropUrl = getClass().getResource(appPropPath);
|
||||
if (appPropUrl == null) {
|
||||
throw new IllegalStateException(
|
||||
"The Ghidra Jar must have an application.properties file at " + appPropPath);
|
||||
}
|
||||
ResourceFile rootDir = fromUrl(appPropUrl).getParentFile();
|
||||
dirs.add(rootDir);
|
||||
return dirs;
|
||||
return List.of(fromUrl(appPropUrl).getParentFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -33,7 +33,7 @@ import ghidra.framework.GModule;
|
|||
public abstract class ApplicationLayout {
|
||||
|
||||
protected ApplicationProperties applicationProperties;
|
||||
protected Collection<ResourceFile> applicationRootDirs;
|
||||
protected SequencedCollection<ResourceFile> applicationRootDirs;
|
||||
protected ResourceFile applicationInstallationDir;
|
||||
protected Map<String, GModule> modules;
|
||||
protected File userTempDir;
|
||||
|
@ -55,9 +55,9 @@ public abstract class ApplicationLayout {
|
|||
/**
|
||||
* Gets the application root directories from the application layout.
|
||||
*
|
||||
* @return A collection of application root directories (or null if not set).
|
||||
* @return A {@link SequencedCollection} of application root directories (or null if not set).
|
||||
*/
|
||||
public final Collection<ResourceFile> getApplicationRootDirs() {
|
||||
public final SequencedCollection<ResourceFile> getApplicationRootDirs() {
|
||||
return applicationRootDirs;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -16,8 +16,7 @@
|
|||
package utility.application;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.framework.*;
|
||||
|
@ -50,8 +49,8 @@ public class ApplicationUtilities {
|
|||
*
|
||||
* @return A collection of discovered application root directories (could be empty).
|
||||
*/
|
||||
public static Collection<ResourceFile> findDefaultApplicationRootDirs() {
|
||||
Collection<ResourceFile> applicationRootDirs = new ArrayList<>();
|
||||
public static SequencedCollection<ResourceFile> findDefaultApplicationRootDirs() {
|
||||
List<ResourceFile> applicationRootDirs = new ArrayList<>();
|
||||
ResourceFile applicationRootDir = findPrimaryApplicationRootDir();
|
||||
if (applicationRootDir != null) {
|
||||
applicationRootDirs.add(applicationRootDir);
|
||||
|
@ -121,11 +120,11 @@ public class ApplicationUtilities {
|
|||
*
|
||||
* @param primaryApplicationRootDir The primary application root directory that may contain the
|
||||
* repository config file one directory up.
|
||||
* @return A collection of defined application repository root directories.
|
||||
* @return A {@link SequencedCollection} of defined application repository root directories.
|
||||
*/
|
||||
private static Collection<ResourceFile> findApplicationRootDirsFromRepoConfig(
|
||||
private static SequencedCollection<ResourceFile> findApplicationRootDirsFromRepoConfig(
|
||||
ResourceFile primaryApplicationRootDir) {
|
||||
Collection<ResourceFile> repoApplicationRootDirs = new ArrayList<>();
|
||||
List<ResourceFile> repoApplicationRootDirs = new ArrayList<>();
|
||||
ResourceFile repoConfigFile =
|
||||
new ResourceFile(primaryApplicationRootDir.getParentFile(), "ghidra.repos.config");
|
||||
if (repoConfigFile.isFile()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue