Skip to content

Commit 9eeb0ab

Browse files
committed
Disabled 'fat' (multiplatform) library check.
1 parent 24d74ca commit 9eeb0ab

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

app/src/processing/app/Base.java

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,21 +1065,40 @@ public Map<String, File> scanLibraries(File folder) {
10651065
}
10661066
return res;
10671067
}
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+
*/
10691083
public File scanFatLibrary(File libFolder) {
10701084
// A library is considered "fat" if there are folders besides
10711085
// examples and utility
10721086
boolean fat = false;
10731087
String[] folders = libFolder.list(new OnlyDirs());
10741088
for (String folder : folders) {
1075-
if (folder.equals("examples"))
1089+
if (folder.equalsIgnoreCase("examples"))
10761090
continue;
1077-
if (folder.equals("utility"))
1091+
if (folder.equalsIgnoreCase("utility"))
10781092
continue;
10791093
fat = true;
10801094
break;
10811095
}
10821096

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+
10831102
if (!fat)
10841103
return libFolder;
10851104

@@ -2612,7 +2631,7 @@ public void handleAddLibrary(Editor editor) {
26122631
JFileChooser fileChooser = new JFileChooser(System.getProperty("user.home"));
26132632
fileChooser.setDialogTitle(_("Select a zip file or a folder containing the library you'd like to add"));
26142633
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"));
26162635

26172636
Dimension preferredSize = fileChooser.getPreferredSize();
26182637
fileChooser.setPreferredSize(new Dimension(preferredSize.width + 200, preferredSize.height + 200));
@@ -2635,7 +2654,7 @@ public void handleAddLibrary(Editor editor) {
26352654
zipDeflater.deflate();
26362655
File[] foldersInTmpFolder = tmpFolder.listFiles(new OnlyDirs());
26372656
if (foldersInTmpFolder.length != 1) {
2638-
throw new IOException("Zip doesn't contain one library");
2657+
throw new IOException(_("Zip doesn't contain a library"));
26392658
}
26402659
sourceFile = foldersInTmpFolder[0];
26412660
} catch (IOException e) {
@@ -2644,22 +2663,27 @@ public void handleAddLibrary(Editor editor) {
26442663
}
26452664
}
26462665

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);
26512675
return;
26522676
}
26532677
String[] headerFiles = headerListFromIncludePath(libFolder);
26542678
if (headerFiles == null || headerFiles.length == 0) {
2655-
editor.statusError("Not a valid library");
2679+
editor.statusError(_("Not a valid library: no header files found"));
26562680
return;
26572681
}
26582682

26592683
// copy folder
26602684
File destinationFolder = new File(getSketchbookLibrariesFolder(), sourceFile.getName());
26612685
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()));
26632687
return;
26642688
}
26652689
try {

0 commit comments

Comments
 (0)