Signed-off-by: Florian Koeberle <florianskarten@xxxxxx> --- .../jgit/lib/fileiteration/GlobalFilePattern.java | 50 ++++++++++++++++++++ 1 files changed, 50 insertions(+), 0 deletions(-) create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/GlobalFilePattern.java diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/GlobalFilePattern.java b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/GlobalFilePattern.java new file mode 100644 index 0000000..92b133f --- /dev/null +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/fileiteration/GlobalFilePattern.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2008 Florian Köberle + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + */ +package org.spearce.jgit.lib.fileiteration; + +class GlobalFilePattern implements FilePattern { + private final StarPattern starPattern; + + private final boolean matchDirectoriesOnly; + + GlobalFilePattern(String starPatternString, boolean matchDirectoriesOnly) { + this.starPattern = new StarPattern(starPatternString); + this.matchDirectoriesOnly = matchDirectoriesOnly; + } + + public boolean canMatchAtThisDirectoryLevel() { + return true; + } + + public FilePattern getPatternForSubDirectory(String directoryName) { + if (match(directoryName, true)) { + return MATCH_ALWAYS; + } + return this; + } + + public boolean match(String fileName, boolean fileIsDirectory) { + if (matchDirectoriesOnly && !fileIsDirectory) { + return false; + } + return starPattern.matches(fileName); + } + + public boolean isSameForSubDirectories() { + return false; + } +} -- 1.5.2.5 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html