@@ -1065,21 +1065,40 @@ public Map<String, File> scanLibraries(File folder) {
1065
1065
}
1066
1066
return res ;
1067
1067
}
1068
-
1068
+
1069
+ /**
1070
+ * <b>XXX FAT lib detection temporary disabled: compatibility issues arised.</b><br/>
1071
+ * <br />
1072
+ * Scans inside a "FAT" (multi-platform) library folder to see if it contains
1073
+ * a version suitable for the actual selected architecture. If a suitable
1074
+ * version is found the folder containing that version is returned, otherwise
1075
+ * <b>null</b> is returned.<br />
1076
+ * <br />
1077
+ * If a non-"FAT" library is detected, we assume that the library is suitable
1078
+ * for the current architecture and the libFolder parameter is returned.<br />
1079
+ *
1080
+ * @param libFolder
1081
+ * @return
1082
+ */
1069
1083
public File scanFatLibrary (File libFolder ) {
1070
1084
// A library is considered "fat" if there are folders besides
1071
1085
// examples and utility
1072
1086
boolean fat = false ;
1073
1087
String [] folders = libFolder .list (new OnlyDirs ());
1074
1088
for (String folder : folders ) {
1075
- if (folder .equals ("examples" ))
1089
+ if (folder .equalsIgnoreCase ("examples" ))
1076
1090
continue ;
1077
- if (folder .equals ("utility" ))
1091
+ if (folder .equalsIgnoreCase ("utility" ))
1078
1092
continue ;
1079
1093
fat = true ;
1080
1094
break ;
1081
1095
}
1082
1096
1097
+ // XXX: Temporary override "FAT" (multiplatform) library detection.
1098
+ // Compatibility issues arised: many library uses additional folders
1099
+ // https://code.google.com/p/arduino/issues/detail?id=1079
1100
+ fat = false ;
1101
+
1083
1102
if (!fat )
1084
1103
return libFolder ;
1085
1104
@@ -2612,7 +2631,7 @@ public void handleAddLibrary(Editor editor) {
2612
2631
JFileChooser fileChooser = new JFileChooser (System .getProperty ("user.home" ));
2613
2632
fileChooser .setDialogTitle (_ ("Select a zip file or a folder containing the library you'd like to add" ));
2614
2633
fileChooser .setFileSelectionMode (JFileChooser .FILES_AND_DIRECTORIES );
2615
- fileChooser .setFileFilter (new FileNameExtensionFilter ("ZIP files or folders" , "zip" ));
2634
+ fileChooser .setFileFilter (new FileNameExtensionFilter (_ ( "ZIP files or folders" ) , "zip" ));
2616
2635
2617
2636
Dimension preferredSize = fileChooser .getPreferredSize ();
2618
2637
fileChooser .setPreferredSize (new Dimension (preferredSize .width + 200 , preferredSize .height + 200 ));
@@ -2635,7 +2654,7 @@ public void handleAddLibrary(Editor editor) {
2635
2654
zipDeflater .deflate ();
2636
2655
File [] foldersInTmpFolder = tmpFolder .listFiles (new OnlyDirs ());
2637
2656
if (foldersInTmpFolder .length != 1 ) {
2638
- throw new IOException ("Zip doesn't contain one library" );
2657
+ throw new IOException (_ ( "Zip doesn't contain a library" ) );
2639
2658
}
2640
2659
sourceFile = foldersInTmpFolder [0 ];
2641
2660
} catch (IOException e ) {
@@ -2644,22 +2663,27 @@ public void handleAddLibrary(Editor editor) {
2644
2663
}
2645
2664
}
2646
2665
2647
- // is there a library?
2648
- File libFolder = scanFatLibrary (sourceFile );
2649
- if (libFolder == null ) {
2650
- editor .statusError ("Not a valid library" );
2666
+ // is there a valid library?
2667
+ File libFolder = sourceFile ;
2668
+ String libName = libFolder .getName ();
2669
+ if (!Sketch .isSanitaryName (libName )) {
2670
+ String mess = I18n .format (_ ("The library \" {0}\" cannot be used.\n "
2671
+ + "Library names must contain only basic letters and numbers.\n "
2672
+ + "(ASCII only and no spaces, and it cannot start with a number)" ),
2673
+ libName );
2674
+ editor .statusError (mess );
2651
2675
return ;
2652
2676
}
2653
2677
String [] headerFiles = headerListFromIncludePath (libFolder );
2654
2678
if (headerFiles == null || headerFiles .length == 0 ) {
2655
- editor .statusError ("Not a valid library" );
2679
+ editor .statusError (_ ( "Not a valid library: no header files found" ) );
2656
2680
return ;
2657
2681
}
2658
2682
2659
2683
// copy folder
2660
2684
File destinationFolder = new File (getSketchbookLibrariesFolder (), sourceFile .getName ());
2661
2685
if (!destinationFolder .mkdir ()) {
2662
- editor .statusError ("A library named " + sourceFile .getName () + " already exists" );
2686
+ editor .statusError (I18n . format ( _ ( "A library named {0} already exists" ), sourceFile .getName ()) );
2663
2687
return ;
2664
2688
}
2665
2689
try {
0 commit comments