@@ -254,6 +254,32 @@ static public File getSketchbookLibrariesFolder() {
254
254
return libdir ;
255
255
}
256
256
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
+
257
283
public static TargetBoard getTargetBoard () {
258
284
String boardId = PreferencesData .get ("board" );
259
285
return getTargetPlatform ().getBoard (boardId );
@@ -552,7 +578,7 @@ static protected void processBoardArgument(String selectBoard) {
552
578
if (targetBoard .getMenuLabel (key , value ) == null )
553
579
showError (null , I18n .format (_ ("{0}: Invalid option for \" {1}\" option for board \" {2}\" " ), value , key , targetBoard .getId ()), 3 );
554
580
555
- Preferences .set ("custom_" + key , targetBoard .getId () + "_" + value );
581
+ PreferencesData .set ("custom_" + key , targetBoard .getId () + "_" + value );
556
582
}
557
583
}
558
584
}
0 commit comments