Mercurial > hg > digilib
changeset 1653:83be6fb35c3f
Filter out filenames starting with a dot.
author | Robert Casties <r0bcas7@gmail.com> |
---|---|
date | Tue, 07 Nov 2017 18:37:45 +0100 |
parents | f41cee9bc61b |
children | 22dd14eccdc0 |
files | common/src/main/java/digilib/io/FileOps.java |
diffstat | 1 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/common/src/main/java/digilib/io/FileOps.java Tue Nov 07 18:36:48 2017 +0100 +++ b/common/src/main/java/digilib/io/FileOps.java Tue Nov 07 18:37:45 2017 +0100 @@ -295,6 +295,23 @@ return pathname.substring(a, e + 1); } + + /** + * Returns if the filename is valid. + * + * Currently only checks if filename starts with a dot. + * + * @param filename + * @return + */ + public static boolean isValidFilename(String filename) { + // exclude filenames starting with a dot + if (filename.startsWith(".")) { + return false; + } + return true; + } + /** * FileFilter for general files */ @@ -311,7 +328,11 @@ static class ImageFileFilter implements FileFilter { public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.IMAGE); + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.IMAGE); + } + return false; } } @@ -320,9 +341,13 @@ */ static class TextFileFilter implements FileFilter { - public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.TEXT); - } + public boolean accept(File f) { + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.TEXT); + } + return false; + } } /** @@ -331,9 +356,13 @@ */ static class SVGFileFilter implements FileFilter { - public boolean accept(File f) { - return (classForFilename(f.getName()) == FileClass.SVG); - } + public boolean accept(File f) { + String fn = f.getName(); + if (isValidFilename(fn)) { + return (classForFilename(fn) == FileClass.SVG); + } + return false; + } } /**