(List<String> outFilenames,
List<String> outExtensions)
| 185 | |
| 186 | |
| 187 | public void getSketchCodeFiles(List<String> outFilenames, |
| 188 | List<String> outExtensions) { |
| 189 | // get list of files in the sketch folder |
| 190 | String list[] = folder.list(); |
| 191 | |
| 192 | for (String filename : list) { |
| 193 | // Ignoring the dot prefix files is especially important to avoid files |
| 194 | // with the ._ prefix on Mac OS X. (You'll see this with Mac files on |
| 195 | // non-HFS drives, i.e. a thumb drive formatted FAT32.) |
| 196 | if (filename.startsWith(".")) continue; |
| 197 | |
| 198 | // Don't let some wacko name a directory blah.pde or bling.java. |
| 199 | if (new File(folder, filename).isDirectory()) continue; |
| 200 | |
| 201 | // figure out the name without any extension |
| 202 | String base = filename; |
| 203 | // now strip off the .pde and .java extensions |
| 204 | for (String extension : mode.getExtensions()) { |
| 205 | if (base.toLowerCase().endsWith("." + extension)) { |
| 206 | base = base.substring(0, base.length() - (extension.length() + 1)); |
| 207 | |
| 208 | // Don't allow people to use files with invalid names, since on load, |
| 209 | // it would be otherwise possible to sneak in nasty filenames. [0116] |
| 210 | if (isSanitaryName(base)) { |
| 211 | if (outFilenames != null) outFilenames.add(filename); |
| 212 | if (outExtensions != null) outExtensions.add(extension); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | |
| 220 | /** |
no test coverage detected