Skip to content

Include library paths used by libraries in the compiler search path (take 2) #1726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FileUtils: added function to recursively find files with given extension
  • Loading branch information
cmaglie committed Dec 8, 2013
commit 60c24eff31f5cc6454ae694f079eca4bc883c582
27 changes: 27 additions & 0 deletions app/src/processing/app/helpers/FileUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package processing.app.helpers;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -188,4 +189,30 @@ public static String readFileToString(File file) throws IOException {
}
}
}

/**
* Recursively find all files in a folder with the specified extension
*
* @param folder
* @param extensions
* @return
*/
public static List<File> listAllFilesWithExtension(File folder, String... extensions) {
List<File> result = new ArrayList<File>();
for (File file : folder.listFiles()) {
if (file.isDirectory()) {
result.addAll(listAllFilesWithExtension(file, extensions));
continue;
}

for (String ext : extensions) {
if (file.getName().endsWith(ext)) {
result.add(file);
break;
}
}
}
return result;
}

}