@@ -462,7 +462,7 @@ public Base(String[] args) throws Exception {
462462 }
463463
464464 boolean showEditor = (action == ACTION .GUI );
465- if (handleOpen (path , nextEditorLocation (), showEditor ) == null ) {
465+ if (handleOpen (new File ( path ) , nextEditorLocation (), showEditor ) == null ) {
466466 String mess = I18n .format (_ ("Failed to open sketch: \" {0}\" " ), path );
467467 // Open failure is fatal in upload/verify mode
468468 if (action == ACTION .VERIFY || action == ACTION .UPLOAD )
@@ -654,7 +654,7 @@ protected boolean restoreSketches() throws Exception {
654654 location = nextEditorLocation ();
655655 }
656656 // If file did not exist, null will be returned for the Editor
657- if (handleOpen (path , location , true ) != null ) {
657+ if (handleOpen (new File ( path ) , location , true ) != null ) {
658658 opened ++;
659659 }
660660 }
@@ -812,7 +812,7 @@ protected int[] nextEditorLocation() {
812812 * @param shift whether shift is pressed, which will invert prompt setting
813813 * @param noPrompt disable prompt, no matter the setting
814814 */
815- protected String createNewUntitled () throws IOException {
815+ protected File createNewUntitled () throws IOException {
816816 File newbieDir = null ;
817817 String newbieName = null ;
818818
@@ -859,7 +859,7 @@ protected String createNewUntitled() throws IOException {
859859 throw new IOException ();
860860 }
861861 FileUtils .copyFile (new File (getContentFile ("examples" ), "01.Basics" + File .separator + "BareMinimum" + File .separator + "BareMinimum.ino" ), newbieFile );
862- return newbieFile . getAbsolutePath () ;
862+ return newbieFile ;
863863 }
864864
865865
@@ -869,9 +869,9 @@ protected String createNewUntitled() throws IOException {
869869 */
870870 public void handleNew () throws Exception {
871871 try {
872- String path = createNewUntitled ();
873- if (path != null ) {
874- Editor editor = handleOpen (path );
872+ File file = createNewUntitled ();
873+ if (file != null ) {
874+ Editor editor = handleOpen (file );
875875 editor .untitled = true ;
876876 }
877877
@@ -900,9 +900,9 @@ public void handleNewReplace() {
900900
901901 protected void handleNewReplaceImpl () {
902902 try {
903- String path = createNewUntitled ();
904- if (path != null ) {
905- activeEditor .handleOpenInternal (path );
903+ File file = createNewUntitled ();
904+ if (file != null ) {
905+ activeEditor .handleOpenInternal (file );
906906 activeEditor .untitled = true ;
907907 }
908908// return true;
@@ -918,14 +918,14 @@ protected void handleNewReplaceImpl() {
918918 * Open a sketch, replacing the sketch in the current window.
919919 * @param path Location of the primary pde file for the sketch.
920920 */
921- public void handleOpenReplace (String path ) {
921+ public void handleOpenReplace (File file ) {
922922 if (!activeEditor .checkModified ()) {
923923 return ; // sketch was modified, and user canceled
924924 }
925925 // Close the running window, avoid window boogers with multiple sketches
926926 activeEditor .internalCloseRunner ();
927927
928- boolean loaded = activeEditor .handleOpenInternal (path );
928+ boolean loaded = activeEditor .handleOpenInternal (file );
929929 if (!loaded ) {
930930 // replace the document without checking if that's ok
931931 handleNewReplaceImpl ();
@@ -956,30 +956,30 @@ public void handleOpenPrompt() throws Exception {
956956 File inputFile = fd .getSelectedFile ();
957957
958958 Preferences .set ("last.folder" , inputFile .getAbsolutePath ());
959- handleOpen (inputFile . getAbsolutePath () );
959+ handleOpen (inputFile );
960960 }
961961
962962
963963 /**
964964 * Open a sketch in a new window.
965- * @param path Path to the pde file for the sketch in question
965+ * @param file File to open
966966 * @return the Editor object, so that properties (like 'untitled')
967967 * can be set by the caller
968968 * @throws Exception
969969 */
970- public Editor handleOpen (String path ) throws Exception {
971- return handleOpen (path , nextEditorLocation (), true );
970+ public Editor handleOpen (File file ) throws Exception {
971+ return handleOpen (file , nextEditorLocation (), true );
972972 }
973973
974974
975- protected Editor handleOpen (String path , int [] location , boolean showEditor ) throws Exception {
975+ protected Editor handleOpen (File file , int [] location , boolean showEditor ) throws Exception {
976976// System.err.println("entering handleOpen " + path);
977977
978- File file = new File (path );
979978 if (!file .exists ()) return null ;
980979
981980// System.err.println(" editors: " + editors);
982981 // Cycle through open windows to make sure that it's not already open.
982+ String path = file .getAbsolutePath ();
983983 for (Editor editor : editors ) {
984984 if (editor .getSketch ().getMainFilePath ().equals (path )) {
985985 editor .toFront ();
@@ -1003,7 +1003,7 @@ protected Editor handleOpen(String path, int[] location, boolean showEditor) thr
10031003// }
10041004
10051005// System.err.println(" creating new editor");
1006- Editor editor = new Editor (this , path , location );
1006+ Editor editor = new Editor (this , file , location );
10071007// Editor editor = null;
10081008// try {
10091009// editor = new Editor(this, path, location);
@@ -1746,16 +1746,17 @@ private boolean addSketchesSubmenu(JMenu menu, String name, File folder,
17461746 ActionListener listener = new ActionListener () {
17471747 public void actionPerformed (ActionEvent e ) {
17481748 String path = e .getActionCommand ();
1749- if (new File (path ).exists ()) {
1749+ File file = new File (path );
1750+ if (file .exists ()) {
17501751 boolean replace = replaceExisting ;
17511752 if ((e .getModifiers () & ActionEvent .SHIFT_MASK ) != 0 ) {
17521753 replace = !replace ;
17531754 }
17541755 if (replace ) {
1755- handleOpenReplace (path );
1756+ handleOpenReplace (file );
17561757 } else {
17571758 try {
1758- handleOpen (path );
1759+ handleOpen (file );
17591760 } catch (Exception e1 ) {
17601761 e1 .printStackTrace ();
17611762 }
0 commit comments