Skip to content

Commit 55b440c

Browse files
author
jantje
committed
Library examples are parsed recursively
The examples has to be in root/examples/folder I changed this to work like the examples provided by arduino which is like in any subfolder where a .ino file is
1 parent ebc7c4a commit 55b440c

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardsManager.java

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static boolean isReady() {
174174
* the board belongs to
175175
*
176176
* If the boardID is null there will be no platform examples
177-
*
177+
*
178178
* @param boardID
179179
* @return
180180
*/
@@ -233,9 +233,9 @@ private static TreeMap<String, IPath> getLibExampleFolders(IPath LibRoot) {
233233
IPath Lib_examples = LibRoot.append(curLib).append("examples");//$NON-NLS-1$
234234
IPath Lib_Examples = LibRoot.append(curLib).append("Examples");//$NON-NLS-1$
235235
if (Lib_examples.toFile().isDirectory()) {
236-
examples.putAll(getExampleFolders(curLib, Lib_examples.toFile()));
236+
examples.putAll(getExamplesFromFolder(curLib, Lib_examples));
237237
} else if (Lib_Examples.toFile().isDirectory()) {
238-
examples.putAll(getExampleFolders(curLib, Lib_Examples.toFile()));
238+
examples.putAll(getExamplesFromFolder(curLib, Lib_Examples));
239239
} else // nothing found directly so maybe this is a version
240240
// based lib
241241
{
@@ -246,9 +246,9 @@ private static TreeMap<String, IPath> getLibExampleFolders(IPath LibRoot) {
246246
Lib_examples = LibRoot.append(curLib).append(versions[0]).append("examples");//$NON-NLS-1$
247247
Lib_Examples = LibRoot.append(curLib).append(versions[0]).append("Examples");//$NON-NLS-1$
248248
if (Lib_examples.toFile().isDirectory()) {
249-
examples.putAll(getExampleFolders(curLib, Lib_examples.toFile()));
249+
examples.putAll(getExamplesFromFolder(curLib, Lib_examples));
250250
} else if (Lib_Examples.toFile().isDirectory()) {
251-
examples.putAll(getExampleFolders(curLib, Lib_Examples.toFile()));
251+
examples.putAll(getExamplesFromFolder(curLib, Lib_Examples));
252252
}
253253
}
254254
}
@@ -258,37 +258,13 @@ private static TreeMap<String, IPath> getLibExampleFolders(IPath LibRoot) {
258258
return examples;
259259
}
260260

261-
/**
262-
* This method adds a folder of examples. There is no search. The provided
263-
* folder is assumed to be a tree where the parents of the leaves are
264-
* assumed examples
265-
*
266-
* @param iPath
267-
* @param pathVarName
268-
*/
269-
private static TreeMap<String, IPath> getExampleFolders(String libname, File location) {
270-
String[] children = location.list();
271-
TreeMap<String, IPath> examples = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
272-
if (children == null) {
273-
// Either dir does not exist or is not a directory
274-
} else {
275-
for (String curFolder : children) {
276-
IPath LibFolder = new Path(location.toString()).append(curFolder);
277-
if (LibFolder.toFile().isDirectory()) {
278-
examples.put(libname + '-' + curFolder, LibFolder);
279-
}
280-
}
281-
}
282-
return examples;
283-
}
284-
285261
/**
286262
* This method adds a folder recursively examples. Leaves containing ino
287263
* files are assumed to be examples
288264
*
289265
* @param File
290266
*/
291-
private static TreeMap<String, IPath> getExamplesFromFolder(String prefix, Path location) {
267+
private static TreeMap<String, IPath> getExamplesFromFolder(String prefix, IPath location) {
292268
TreeMap<String, IPath> examples = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
293269
File[] children = location.toFile().listFiles();
294270
if (children == null) {

0 commit comments

Comments
 (0)