| | |
| | | for (File f : files) { |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | String extName = FileHelper.getExtension(fileName); |
| | | if (!isExtValid(extName)) { |
| | | if (!isFileValid(f.getName())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | private void getFilesByPath(List<File> list, String path) { |
| | | File file = new File(path); |
| | | if (!file.isDirectory()) { |
| | | String extName = FileHelper.getExtension(file); |
| | | if (isExtValid(extName)) { |
| | | if (isFileValid(file.getName())) { |
| | | list.add(file); |
| | | } |
| | | return; |
| | |
| | | if (f.isDirectory()) { |
| | | getFilesByPath(list, f.getPath()); |
| | | } else { |
| | | String extName = FileHelper.getExtension(f); |
| | | if (isExtValid(extName)) { |
| | | if (isFileValid(f.getName())) { |
| | | list.add(f); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 扩展是否有效 |
| | | * 文件是/否有效 |
| | | */ |
| | | private boolean isExtValid(String extName) { |
| | | return StaticData.ALL_EXTENSION.contains(extName) && !StaticData.MAPPER_EXCLUDE_EXT.contains(extName); |
| | | private boolean isFileValid(String fileName) { |
| | | String extName = FileHelper.getExtension(fileName); |
| | | if (fileName.startsWith(StaticData.TILDE) || !StaticData.ALL_EXTENSION.contains(extName)) { |
| | | return false; |
| | | } |
| | | |
| | | fileName = fileName.toLowerCase(); |
| | | for (String ext : StaticData.MAPPER_EXCLUDE_EXT) { |
| | | if (fileName.contains(ext)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | String fileName = FileHelper.getFileName(f.getPath()); |
| | | String extName = isOsgb ? StaticData.OSGB : FileHelper.getExtension(fileName); |
| | | if (!isExtValid(extName) || fileName.startsWith("~")) { |
| | | if (!isFileValid(f.getName())) { |
| | | continue; |
| | | } |
| | | |