mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-10 06:02:09 +00:00
GP-4057 Corrected ProjectLocator bug and corrected use of various
directory preferences to varefy directory existance.
This commit is contained in:
parent
bb4a9ccbb1
commit
af160d946d
@ -394,9 +394,9 @@ public class RestoreDialog extends ReusableDialogComponentProvider {
|
||||
jarFileChooser.setTitle("Restore a Ghidra Project - Archive");
|
||||
String lastDirSelected = Preferences.getProperty(ArchivePlugin.LAST_ARCHIVE_DIR);
|
||||
if (lastDirSelected != null) {
|
||||
File file = new File(lastDirSelected);
|
||||
if (file.exists()) {
|
||||
jarFileChooser.setCurrentDirectory(file);
|
||||
File dir = new File(lastDirSelected);
|
||||
if (dir.isDirectory()) {
|
||||
jarFileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
File jarFile = null;
|
||||
|
@ -261,9 +261,9 @@ public class ExportToHeaderAction extends DockingAction {
|
||||
|
||||
String lastDirSelected = Preferences.getProperty(LAST_DATA_TYPE_EXPORT_DIRECTORY);
|
||||
if (lastDirSelected != null) {
|
||||
File file = new File(lastDirSelected);
|
||||
if (file.exists()) {
|
||||
fileChooser.setCurrentDirectory(file);
|
||||
File dir = new File(lastDirSelected);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,10 @@ public class ExportPatternFileActionListener implements ActionListener {
|
||||
gFileChooser.setFileFilter(xmlFilter);
|
||||
String baseDir = Preferences.getProperty(XML_EXPORT_DIR_PROPERTY);
|
||||
if (baseDir != null) {
|
||||
gFileChooser.setCurrentDirectory(new File(baseDir));
|
||||
File dir = new File(baseDir);
|
||||
if (dir.isDirectory()) {
|
||||
gFileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
gFileChooser.setTitle("Select Export File");
|
||||
File outFile = gFileChooser.getSelectedFile();
|
||||
|
@ -233,7 +233,10 @@ public class FunctionBitPatternsMainProvider extends ComponentProviderAdapter
|
||||
fileChooser.setTitle("Select Directory Containing XML Files");
|
||||
String baseDir = Preferences.getProperty(PATTERN_INFO_DIR);
|
||||
if (baseDir != null) {
|
||||
fileChooser.setCurrentDirectory(new File(baseDir));
|
||||
File dir = new File(baseDir);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
File xmlDir = fileChooser.getSelectedFile();
|
||||
fileChooser.dispose();
|
||||
|
@ -64,7 +64,10 @@ public class ImportPatternFileActionListener implements ActionListener {
|
||||
fileChooser.setTitle("Select Pattern File");
|
||||
String baseDir = Preferences.getProperty(XML_IMPORT_DIR_PROPERTY);
|
||||
if (baseDir != null) {
|
||||
fileChooser.setCurrentDirectory(new File(baseDir));
|
||||
File dir = new File(baseDir);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
ExtensionFileFilter xmlFilter = new ExtensionFileFilter("xml", "XML Files");
|
||||
fileChooser.setFileFilter(xmlFilter);
|
||||
|
@ -932,9 +932,11 @@ public class KeyBindingUtils {
|
||||
private static File getStartingDir() {
|
||||
String lastDirectoryPath = Preferences.getProperty(LAST_KEY_BINDING_EXPORT_DIRECTORY);
|
||||
if (lastDirectoryPath != null) {
|
||||
return new File(lastDirectoryPath);
|
||||
File dir = new File(lastDirectoryPath);
|
||||
if (dir.isDirectory()) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
return new File(System.getProperty("user.home"));
|
||||
}
|
||||
|
||||
|
@ -310,9 +310,12 @@ public class PathManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
String dir = Preferences.getProperty(preferenceForLastSelectedDir);
|
||||
if (dir != null) {
|
||||
fileChooser.setCurrentDirectory(new File(dir));
|
||||
String dirPath = Preferences.getProperty(preferenceForLastSelectedDir);
|
||||
if (dirPath != null) {
|
||||
File dir = new File(dirPath);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
List<File> files = fileChooser.getSelectedFiles();
|
||||
|
@ -312,9 +312,12 @@ public class PathnameTablePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
}
|
||||
String dir = Preferences.getProperty(preferenceForLastSelectedDir);
|
||||
if (dir != null) {
|
||||
fileChooser.setCurrentDirectory(new File(dir));
|
||||
String dirPath = Preferences.getProperty(preferenceForLastSelectedDir);
|
||||
if (dirPath != null) {
|
||||
File dir = new File(dirPath);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
List<File> files = fileChooser.getSelectedFiles();
|
||||
|
@ -137,15 +137,22 @@ class SelectProjectPanel extends AbstractWizardJPanel {
|
||||
directoryField = new JTextField(25);
|
||||
directoryField.setName("Project Directory");
|
||||
|
||||
String lastDirSelected = Preferences.getProperty(Preferences.LAST_NEW_PROJECT_DIRECTORY);
|
||||
if (lastDirSelected != null) {
|
||||
directoryField.setText(lastDirSelected);
|
||||
File projectDirectory = null;
|
||||
String projectDirPath = Preferences.getProperty(Preferences.LAST_NEW_PROJECT_DIRECTORY);
|
||||
if (projectDirPath != null) {
|
||||
// if it exists, use last directory where project was created
|
||||
projectDirectory = new File(projectDirPath);
|
||||
if (!projectDirectory.isDirectory()) {
|
||||
projectDirectory = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
File projectDirectory = new File(GenericRunInfo.getProjectsDirPath());
|
||||
directoryField.setText(projectDirectory.getAbsolutePath());
|
||||
if (projectDirectory == null) {
|
||||
// otherwise, use last project directory or default
|
||||
projectDirectory = new File(GenericRunInfo.getProjectsDirPath());
|
||||
}
|
||||
directoryField.setCaretPosition(directoryField.getText().length() - 1);
|
||||
projectDirPath = projectDirectory.getAbsolutePath();
|
||||
directoryField.setText(projectDirPath);
|
||||
directoryField.setCaretPosition(projectDirPath.length() - 1);
|
||||
JLabel projectNameLabel = new GDLabel("Project Name:", SwingConstants.RIGHT);
|
||||
projectNameField = new JTextField(25);
|
||||
projectNameField.setName("Project Name");
|
||||
|
@ -423,7 +423,10 @@ class ToolActionManager implements ToolChestChangeListener {
|
||||
|
||||
String importDir = Preferences.getProperty(Preferences.LAST_TOOL_IMPORT_DIRECTORY);
|
||||
if (importDir != null) {
|
||||
fileChooser.setCurrentDirectory(new File(importDir));
|
||||
File dir = new File(importDir);
|
||||
if (dir.isDirectory()) {
|
||||
fileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
fileChooser.rescanCurrentDirectory();
|
||||
|
@ -125,8 +125,8 @@ public class ProjectLocator {
|
||||
scanIndex = 4;
|
||||
}
|
||||
checkInvalidChar("path", path, scanIndex);
|
||||
if (!path.endsWith(File.separator)) {
|
||||
path += File.separator;
|
||||
if (!path.endsWith("/")) {
|
||||
path += "/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
@ -394,7 +394,10 @@ public class SaveToolConfigDialog extends DialogComponentProvider implements Lis
|
||||
new ExtensionFileFilter(new String[] { "gif", "jpg", "bmp", "png" }, "Image Files"));
|
||||
String iconDir = Preferences.getProperty(LAST_ICON_DIRECTORY);
|
||||
if (iconDir != null) {
|
||||
chooser.setCurrentDirectory(new File(iconDir));
|
||||
File dir = new File(iconDir);
|
||||
if (dir.isDirectory()) {
|
||||
chooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
File file = chooser.getSelectedFile();
|
||||
chooser.dispose();
|
||||
|
@ -145,7 +145,10 @@ class ToolServicesImpl implements ToolServices {
|
||||
|
||||
String exportDir = Preferences.getProperty(Preferences.LAST_TOOL_EXPORT_DIRECTORY);
|
||||
if (exportDir != null) {
|
||||
newFileChooser.setCurrentDirectory(new File(exportDir));
|
||||
File dir = new File(exportDir);
|
||||
if (dir.isDirectory()) {
|
||||
newFileChooser.setCurrentDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
newFileChooser.setTitle("Export Tool");
|
||||
|
@ -401,7 +401,10 @@ public class SpecExtensionPanel extends JPanel {
|
||||
private static File getStartingDir() {
|
||||
String lastDirectoryPath = Preferences.getProperty(LAST_EXPORT_DIRECTORY);
|
||||
if (lastDirectoryPath != null) {
|
||||
return new File(lastDirectoryPath);
|
||||
File dir = new File(lastDirectoryPath);
|
||||
if (dir.isDirectory()) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
return new File(System.getProperty("user.home"));
|
||||
|
Loading…
Reference in New Issue
Block a user