From d133365cc17ed6e814ded79522368a0ecda4ed0d Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Mon, 28 Oct 2013 10:10:14 +0100 Subject: [PATCH] IDE command line: sketches can now be specified with relative paths. Fixes #1493 --- app/src/processing/app/Base.java | 10 ++++++++++ build/linux/dist/arduino | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 5ca58060b..7162c3841 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -324,6 +324,7 @@ public class Base { boolean doVerbose = false; String selectBoard = null; String selectPort = null; + String currentDirectory = System.getProperty("user.dir"); // Check if any files were passed in on the command line for (int i = 0; i < args.length; i++) { if (args[i].equals("--upload")) { @@ -350,6 +351,12 @@ public class Base { selectPort = args[i]; continue; } + if (args[i].equals("--curdir")) { + i++; + if (i < args.length) + currentDirectory = args[i]; + continue; + } String path = args[i]; // Fix a problem with systems that use a non-ASCII languages. Paths are // being passed in with 8.3 syntax, which makes the sketch loader code @@ -363,6 +370,9 @@ public class Base { e.printStackTrace(); } } + if (!new File(path).exists()) { + path = new File(currentDirectory, path).getAbsolutePath(); + } if (handleOpen(path) != null) { opened = true; } diff --git a/build/linux/dist/arduino b/build/linux/dist/arduino index b5eb9dbd5..63811c20e 100755 --- a/build/linux/dist/arduino +++ b/build/linux/dist/arduino @@ -1,9 +1,10 @@ #!/bin/sh - + +CURDIR=`pwd` APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )" cd "$APPDIR" - + for LIB in \ java/lib/rt.jar \ java/lib/tools.jar \ @@ -19,4 +20,5 @@ export LD_LIBRARY_PATH export PATH="${APPDIR}/java/bin:${PATH}" -java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base "$@" +java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base --curdir $CURDIR "$@" +