[Japi-cvs] SF.net SVN: japi:[1410] libs/util/trunk/src/prj/net/sf/japi/util/filter/ file/EndingFile
Status: Beta
Brought to you by:
christianhujer
From: <aki...@us...> - 2010-12-20 20:26:05
|
Revision: 1410 http://japi.svn.sourceforge.net/japi/?rev=1410&view=rev Author: akirschbaum Date: 2010-12-20 20:25:59 +0000 (Mon, 20 Dec 2010) Log Message: ----------- Use case-insensitive comparisons on case-insensitive file systems. Modified Paths: -------------- libs/util/trunk/src/prj/net/sf/japi/util/filter/file/EndingFileFilter.java Modified: libs/util/trunk/src/prj/net/sf/japi/util/filter/file/EndingFileFilter.java =================================================================== --- libs/util/trunk/src/prj/net/sf/japi/util/filter/file/EndingFileFilter.java 2010-06-18 21:28:32 UTC (rev 1409) +++ libs/util/trunk/src/prj/net/sf/japi/util/filter/file/EndingFileFilter.java 2010-12-20 20:25:59 UTC (rev 1410) @@ -30,6 +30,9 @@ */ public class EndingFileFilter extends AbstractFileFilter { + /** Whether the file system is case-insensitive. */ + private static final boolean CASE_INSENSITIVE_FILE_SYSTEM = new File("a").equals(new File("A")); + /** Whether to accept directories. */ private final boolean acceptDirectories; @@ -66,6 +69,11 @@ this.negate = negate; this.description = description; this.endings = endings.clone(); + if (CASE_INSENSITIVE_FILE_SYSTEM) { + for (int i = 0; i < this.endings.length; i++) { + this.endings[i] = this.endings[i].toLowerCase(); + } + } } /** {@inheritDoc} */ @@ -78,7 +86,7 @@ if (pathname.isDirectory()) { return acceptDirectories; } - final String fileName = pathname.getName(); + final String fileName = CASE_INSENSITIVE_FILE_SYSTEM ? pathname.getName().toLowerCase() : pathname.getName(); for (final String ending : endings) { if (fileName.endsWith(ending)) { return !negate; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |