mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Take into account --curdir for all relative paths
In a lot of places, (potentially) relative paths were passed to File without any processing, making them be resolved without taking into account --curdir. By passing them through Base.absoluteFile instead, these paths are resolved relative to the working directory before starting arduino (at least on Linux, which is currently the only platform supporting --curdir). This applies --curdir to the --preferences-file option and the build.path, settings.path, sketchbook.path preferences. For example, this now works as expected: arduino --pref build.path=build_dir --verify Blink.ino
This commit is contained in:
committed by
Cristian Maglie
parent
4f33d0851c
commit
cc773fb1e0
@ -143,7 +143,7 @@ public class Base {
|
|||||||
if (!portableFolder.exists())
|
if (!portableFolder.exists())
|
||||||
portableFolder = null;
|
portableFolder = null;
|
||||||
|
|
||||||
File preferencesFile = null;
|
String preferencesFile = null;
|
||||||
|
|
||||||
// Do a first pass over the commandline arguments, the rest of them
|
// Do a first pass over the commandline arguments, the rest of them
|
||||||
// will be processed by the Base constructor. Note that this loop
|
// will be processed by the Base constructor. Note that this loop
|
||||||
@ -153,7 +153,7 @@ public class Base {
|
|||||||
for (int i = 0; i < args.length - 1; i++) {
|
for (int i = 0; i < args.length - 1; i++) {
|
||||||
if (args[i].equals("--preferences-file")) {
|
if (args[i].equals("--preferences-file")) {
|
||||||
++i;
|
++i;
|
||||||
preferencesFile = new File(args[i]);
|
preferencesFile = args[i];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[i].equals("--curdir")) {
|
if (args[i].equals("--curdir")) {
|
||||||
@ -164,7 +164,7 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run static initialization that grabs all the prefs
|
// run static initialization that grabs all the prefs
|
||||||
Preferences.init(preferencesFile);
|
Preferences.init(absoluteFile(preferencesFile));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File versionFile = getContentFile("lib/version.txt");
|
File versionFile = getContentFile("lib/version.txt");
|
||||||
@ -296,6 +296,8 @@ public class Base {
|
|||||||
// directory when starting the IDE (which is not the same as the
|
// directory when starting the IDE (which is not the same as the
|
||||||
// current working directory!).
|
// current working directory!).
|
||||||
static public File absoluteFile(String path) {
|
static public File absoluteFile(String path) {
|
||||||
|
if (path == null) return null;
|
||||||
|
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
if (!file.isAbsolute()) {
|
if (!file.isAbsolute()) {
|
||||||
file = new File(currentDirectory, path);
|
file = new File(currentDirectory, path);
|
||||||
@ -320,7 +322,7 @@ public class Base {
|
|||||||
if (portableFolder != null)
|
if (portableFolder != null)
|
||||||
sketchbookFolder = new File(portableFolder, sketchbookPath);
|
sketchbookFolder = new File(portableFolder, sketchbookPath);
|
||||||
else
|
else
|
||||||
sketchbookFolder = new File(sketchbookPath);
|
sketchbookFolder = Base.absoluteFile(sketchbookPath);
|
||||||
if (!sketchbookFolder.exists()) {
|
if (!sketchbookFolder.exists()) {
|
||||||
Base.showWarning(_("Sketchbook folder disappeared"),
|
Base.showWarning(_("Sketchbook folder disappeared"),
|
||||||
_("The sketchbook folder no longer exists.\n" +
|
_("The sketchbook folder no longer exists.\n" +
|
||||||
@ -2047,7 +2049,7 @@ public class Base {
|
|||||||
|
|
||||||
String preferencesPath = Preferences.get("settings.path");
|
String preferencesPath = Preferences.get("settings.path");
|
||||||
if (preferencesPath != null) {
|
if (preferencesPath != null) {
|
||||||
settingsFolder = new File(preferencesPath);
|
settingsFolder = absoluteFile(preferencesPath);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -2086,8 +2088,7 @@ public class Base {
|
|||||||
if (buildFolder == null) {
|
if (buildFolder == null) {
|
||||||
String buildPath = Preferences.get("build.path");
|
String buildPath = Preferences.get("build.path");
|
||||||
if (buildPath != null) {
|
if (buildPath != null) {
|
||||||
buildFolder = new File(buildPath);
|
buildFolder = Base.absoluteFile(buildPath);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//File folder = new File(getTempFolder(), "build");
|
//File folder = new File(getTempFolder(), "build");
|
||||||
//if (!folder.exists()) folder.mkdirs();
|
//if (!folder.exists()) folder.mkdirs();
|
||||||
@ -2248,7 +2249,7 @@ public class Base {
|
|||||||
static public File getSketchbookFolder() {
|
static public File getSketchbookFolder() {
|
||||||
if (portableFolder != null)
|
if (portableFolder != null)
|
||||||
return new File(portableFolder, Preferences.get("sketchbook.path"));
|
return new File(portableFolder, Preferences.get("sketchbook.path"));
|
||||||
return new File(Preferences.get("sketchbook.path"));
|
return absoluteFile(Preferences.get("sketchbook.path"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,6 +280,13 @@ HISTORY
|
|||||||
file, just like *--pref*. The *--verbose* options still only
|
file, just like *--pref*. The *--verbose* options still only
|
||||||
apply to the current run.
|
apply to the current run.
|
||||||
|
|
||||||
|
{empty}::
|
||||||
|
A path passed to *--preferences-file*, or set in the
|
||||||
|
*build.path*, *preferences.path* or *settings.path* is now
|
||||||
|
interpreted relative to the current directory instead of the
|
||||||
|
location of the arduino command itself.
|
||||||
|
|
||||||
|
|
||||||
RESOURCES
|
RESOURCES
|
||||||
---------
|
---------
|
||||||
Web site: <http://arduino.cc/>
|
Web site: <http://arduino.cc/>
|
||||||
|
Reference in New Issue
Block a user