@@ -254,6 +254,32 @@ static public File getSketchbookLibrariesFolder() {
254254 return libdir ;
255255 }
256256
257+ static public String getSketchbookPath () {
258+ // Get the sketchbook path, and make sure it's set properly
259+ String sketchbookPath = Preferences .get ("sketchbook.path" );
260+
261+ // If a value is at least set, first check to see if the folder exists.
262+ // If it doesn't, warn the user that the sketchbook folder is being reset.
263+ if (sketchbookPath != null ) {
264+ File sketchbookFolder ;
265+ if (BaseNoGui .getPortableFolder () != null )
266+ sketchbookFolder = new File (BaseNoGui .getPortableFolder (), sketchbookPath );
267+ else
268+ sketchbookFolder = absoluteFile (sketchbookPath );
269+ if (!sketchbookFolder .exists ()) {
270+ showWarning (_ ("Sketchbook folder disappeared" ),
271+ _ ("The sketchbook folder no longer exists.\n " +
272+ "Arduino will switch to the default sketchbook\n " +
273+ "location, and create a new sketchbook folder if\n " +
274+ "necessary. Arduino will then stop talking about\n " +
275+ "himself in the third person." ), null );
276+ sketchbookPath = null ;
277+ }
278+ }
279+
280+ return sketchbookPath ;
281+ }
282+
257283 public static TargetBoard getTargetBoard () {
258284 String boardId = PreferencesData .get ("board" );
259285 return getTargetPlatform ().getBoard (boardId );
@@ -552,7 +578,7 @@ static protected void processBoardArgument(String selectBoard) {
552578 if (targetBoard .getMenuLabel (key , value ) == null )
553579 showError (null , I18n .format (_ ("{0}: Invalid option for \" {1}\" option for board \" {2}\" " ), value , key , targetBoard .getId ()), 3 );
554580
555- Preferences .set ("custom_" + key , targetBoard .getId () + "_" + value );
581+ PreferencesData .set ("custom_" + key , targetBoard .getId () + "_" + value );
556582 }
557583 }
558584 }
0 commit comments