Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d133365

Browse files
author
Federico Fissore
committedOct 28, 2013
IDE command line: sketches can now be specified with relative paths. Fixes #1493
1 parent 26ff527 commit d133365

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed
 

‎app/src/processing/app/Base.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ public Base(String[] args) throws Exception {
324324
boolean doVerbose = false;
325325
String selectBoard = null;
326326
String selectPort = null;
327+
String currentDirectory = System.getProperty("user.dir");
327328
// Check if any files were passed in on the command line
328329
for (int i = 0; i < args.length; i++) {
329330
if (args[i].equals("--upload")) {
@@ -350,6 +351,12 @@ public Base(String[] args) throws Exception {
350351
selectPort = args[i];
351352
continue;
352353
}
354+
if (args[i].equals("--curdir")) {
355+
i++;
356+
if (i < args.length)
357+
currentDirectory = args[i];
358+
continue;
359+
}
353360
String path = args[i];
354361
// Fix a problem with systems that use a non-ASCII languages. Paths are
355362
// being passed in with 8.3 syntax, which makes the sketch loader code
@@ -363,6 +370,9 @@ public Base(String[] args) throws Exception {
363370
e.printStackTrace();
364371
}
365372
}
373+
if (!new File(path).exists()) {

Comment on line R373

matthijskooijman commented on Oct 28, 2013

@matthijskooijman
Collaborator

This looks wrong to me: If a file with the right name happens to exist within the Arduino install location, it will be opened instead of the file intended in the current directory. Even though it's unlikely that this will happen, it is still an unexpected corner case. This should be easy to fix by using isAbsolute() instead of exists().

Furthermore, I wonder if it would perhaps make sense to perhaps use this currentDirectory for other paths as well (I'm thinking of build.path in particular, but I'm working on some related patches as well, so I might include something for this).

ffissore replied on Oct 28, 2013

@ffissore
Contributor

Good point

Code has comments. Press enter to view.
374+
path = new File(currentDirectory, path).getAbsolutePath();
375+
}
366376
if (handleOpen(path) != null) {
367377
opened = true;
368378
}

‎build/linux/dist/arduino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/sh
2-
2+
3+
CURDIR=`pwd`
34
APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )"
45

56
cd "$APPDIR"
6-
7+
78
for LIB in \
89
java/lib/rt.jar \
910
java/lib/tools.jar \
@@ -19,4 +20,5 @@ export LD_LIBRARY_PATH
1920

2021
export PATH="${APPDIR}/java/bin:${PATH}"
2122

22-
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base "$@"
23+
java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base --curdir $CURDIR "$@"
24+

0 commit comments

Comments
 (0)
Please sign in to comment.