MCPcopy
hub / github.com/arduino/Arduino / addSketches

Method addSketches

app/src/processing/app/Base.java:1747–1773  ·  view source on GitHub ↗

Scan a folder recursively, and add any sketches found to the menu specified. Set the openReplaces parameter to true when opening the sketch should replace the sketch in the current window, or false when the sketch should open in a new window.

(JMenu menu, File folder)

Source from the content-addressed store, hash-verified

1745 * sketch should open in a new window.
1746 */
1747 protected boolean addSketches(JMenu menu, File folder) {
1748 if (folder == null)
1749 return false;
1750
1751 if (!folder.isDirectory()) return false;
1752
1753 File[] files = folder.listFiles();
1754 // If a bad folder or unreadable or whatever, this will come back null
1755 if (files == null) return false;
1756
1757 // Alphabetize files, since it's not always alpha order
1758 Arrays.sort(files, new Comparator<File>() {
1759 @Override
1760 public int compare(File file, File file2) {
1761 return file.getName().compareToIgnoreCase(file2.getName());
1762 }
1763 });
1764
1765 boolean ifound = false;
1766 for (File subfolder : files) {
1767 if (!FileUtils.isSCCSOrHiddenFile(subfolder) && subfolder.isDirectory()
1768 && addSketchesSubmenu(menu, subfolder.getName(), subfolder)) {
1769 ifound = true;
1770 }
1771 }
1772 return ifound;
1773 }
1774
1775 private boolean addSketchesSubmenu(JMenu menu, UserLibrary lib) {
1776 return addSketchesSubmenu(menu, lib.getName(), lib.getInstalledFolder());

Callers 4

rebuildToolbarMenuMethod · 0.95
rebuildSketchbookMenuMethod · 0.95
rebuildExamplesMenuMethod · 0.95
addSketchesSubmenuMethod · 0.95

Calls 5

isSCCSOrHiddenFileMethod · 0.95
addSketchesSubmenuMethod · 0.95
listFilesMethod · 0.80
sortMethod · 0.80
getNameMethod · 0.65

Tested by

no test coverage detected