mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Added command line option "--preferences-file" to manually set the path of preferences.
This commit is contained in:
parent
dd02dcffab
commit
895d394565
@ -140,7 +140,7 @@ public class Base {
|
|||||||
portableFolder = null;
|
portableFolder = null;
|
||||||
|
|
||||||
// run static initialization that grabs all the prefs
|
// run static initialization that grabs all the prefs
|
||||||
Preferences.init(null);
|
Preferences.init(args);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File versionFile = getContentFile("lib/version.txt");
|
File versionFile = getContentFile("lib/version.txt");
|
||||||
@ -368,6 +368,13 @@ public class Base {
|
|||||||
processPrefArgument(args[i]);
|
processPrefArgument(args[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[i].equals("--preferences-file")) {
|
||||||
|
i++;
|
||||||
|
if (i >= args.length)
|
||||||
|
showError(null, "Argument required for --preferences-file", 3);
|
||||||
|
// Argument should be already processed by Preferences.init(...)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (args[i].startsWith("--"))
|
if (args[i].startsWith("--"))
|
||||||
showError(null, I18n.format(_("unknown option: {0}"), args[i]), 3);
|
showError(null, I18n.format(_("unknown option: {0}"), args[i]), 3);
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ public class Preferences {
|
|||||||
static File preferencesFile;
|
static File preferencesFile;
|
||||||
|
|
||||||
|
|
||||||
static protected void init(String commandLinePrefs) {
|
static protected void init(String args[]) {
|
||||||
|
|
||||||
// start by loading the defaults, in case something
|
// start by loading the defaults, in case something
|
||||||
// important was deleted from the user prefs
|
// important was deleted from the user prefs
|
||||||
@ -250,41 +250,31 @@ public class Preferences {
|
|||||||
// clone the hash table
|
// clone the hash table
|
||||||
defaults = new Hashtable<String, String>(table);
|
defaults = new Hashtable<String, String>(table);
|
||||||
|
|
||||||
// Load a prefs file if specified on the command line
|
// next load user preferences file
|
||||||
if (commandLinePrefs != null) {
|
preferencesFile = Base.getSettingsFile(PREFS_FILE);
|
||||||
try {
|
|
||||||
load(new FileInputStream(commandLinePrefs));
|
|
||||||
|
|
||||||
} catch (Exception poe) {
|
// load a preferences file if specified on the command line
|
||||||
Base.showError(_("Error"),
|
if (args != null) {
|
||||||
I18n.format(
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
_("Could not read preferences from {0}"),
|
if (args[i].equals("--preferences-file"))
|
||||||
commandLinePrefs
|
preferencesFile = new File(args[i + 1]);
|
||||||
), poe);
|
|
||||||
}
|
}
|
||||||
} else if (!Base.isCommandLine()) {
|
}
|
||||||
// next load user preferences file
|
|
||||||
preferencesFile = Base.getSettingsFile(PREFS_FILE);
|
|
||||||
if (!preferencesFile.exists()) {
|
|
||||||
// create a new preferences file if none exists
|
|
||||||
// saves the defaults out to the file
|
|
||||||
save();
|
|
||||||
|
|
||||||
} else {
|
if (!preferencesFile.exists()) {
|
||||||
// load the previous preferences file
|
// create a new preferences file if none exists
|
||||||
|
// saves the defaults out to the file
|
||||||
try {
|
save();
|
||||||
load(new FileInputStream(preferencesFile));
|
} else {
|
||||||
|
// load the previous preferences file
|
||||||
} catch (Exception ex) {
|
try {
|
||||||
Base.showError(_("Error reading preferences"),
|
load(new FileInputStream(preferencesFile));
|
||||||
I18n.format(
|
} catch (Exception ex) {
|
||||||
_("Error reading the preferences file. " +
|
Base.showError(_("Error reading preferences"),
|
||||||
"Please delete (or move)\n" +
|
I18n.format(_("Error reading the preferences file. "
|
||||||
"{0} and restart Arduino."),
|
+ "Please delete (or move)\n"
|
||||||
preferencesFile.getAbsolutePath()
|
+ "{0} and restart Arduino."),
|
||||||
), ex);
|
preferencesFile.getAbsolutePath()), ex);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user