|
| 1 | +/* |
| 2 | + OnlyDirs - FilenameFilter that accepts only directories (CVS, .svn, |
| 3 | + .DS_Store files are excluded as well) |
| 4 | + Part of the Arduino project - http://www.arduino.cc/ |
| 5 | +
|
| 6 | + Copyright (c) 2011 Cristian Maglie |
| 7 | +
|
| 8 | + This program is free software; you can redistribute it and/or modify |
| 9 | + it under the terms of the GNU General Public License as published by |
| 10 | + the Free Software Foundation; either version 2 of the License, or |
| 11 | + (at your option) any later version. |
| 12 | +
|
| 13 | + This program is distributed in the hope that it will be useful, |
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + GNU General Public License for more details. |
| 17 | +
|
| 18 | + You should have received a copy of the GNU General Public License |
| 19 | + along with this program; if not, write to the Free Software Foundation, |
| 20 | + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | + */ |
| 22 | +package processing.app.helpers.filefilters; |
| 23 | + |
| 24 | +import java.io.File; |
| 25 | +import java.io.FilenameFilter; |
| 26 | + |
| 27 | +/** |
| 28 | + * This filter accepts only directories (excluding .DS_Store files, .svn |
| 29 | + * folders, etc) |
| 30 | + * |
| 31 | + * @author Cristian Maglie |
| 32 | + */ |
| 33 | +public class OnlyDirs implements FilenameFilter { |
| 34 | + |
| 35 | + public boolean accept(File dir, String name) { |
| 36 | + if (name.charAt(0) == '.') |
| 37 | + return false; |
| 38 | + if (name.equals("CVS")) |
| 39 | + return false; |
| 40 | + return new File(dir, name).isDirectory(); |
| 41 | + } |
| 42 | +} |
0 commit comments