mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
GP-5010: GhidraScript.askFile() no longer throws an
IllegalArgumentException in headless mode when passing in a valid path argument to a file that does not yet exist (Closes #7025)
This commit is contained in:
parent
1929645373
commit
7d5a514f25
@ -1866,21 +1866,6 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
||||
return Arrays.asList(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a file from a string.
|
||||
*
|
||||
* @param s The string to parse.
|
||||
* @return The file that was parsed from the string.
|
||||
* @throws IllegalArgumentException if the parsed value is not a valid file.
|
||||
*/
|
||||
public File parseFile(String s) {
|
||||
File f = new File(s);
|
||||
if (!f.isFile()) {
|
||||
throw new IllegalArgumentException("Invalid file: " + f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to locate a value from script arguments
|
||||
* or a script properties file using
|
||||
@ -1929,7 +1914,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
||||
|
||||
if (isHeadless && !hasDefault) { // require either a props file or a default value
|
||||
throw new IllegalArgumentException("Error processing variable '" + propertyKey +
|
||||
"' in headless mode -- it was not found in a .properties file.");
|
||||
"' in headless mode -- it was not found in script arguments or a .properties file.");
|
||||
}
|
||||
return defaultValue; // may be null
|
||||
}
|
||||
@ -1939,7 +1924,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
||||
|
||||
if (isHeadless && !hasDefault) { // require either a props file or a default value
|
||||
throw new IllegalArgumentException("Error processing variable '" + propertyKey +
|
||||
"' in headless mode -- it was not found in a .properties file.");
|
||||
"' in headless mode -- it was not found in script arguments or a .properties file.");
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
@ -2026,8 +2011,8 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
||||
* exists).
|
||||
* </li>
|
||||
* <li>In the headless environment, this method returns a File object representing the
|
||||
* .properties String value (if it exists), or throws an Exception if there is an
|
||||
* invalid or missing .properties value.
|
||||
* .properties String value, or throws an Exception if there is an invalid or missing
|
||||
* .properties value.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
@ -2045,7 +2030,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
||||
throws CancelledException {
|
||||
|
||||
String key = join(title, approveButtonText);
|
||||
File existingValue = loadAskValue(this::parseFile, key);
|
||||
File existingValue = loadAskValue(File::new, key);
|
||||
if (isRunningHeadless()) {
|
||||
return existingValue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user