Permalink
Browse files

changing the wildcard system to work better on windows

  • Loading branch information...
1 parent f30a8e4 commit 88d759b0e4237c19e85ffcf025faed8975578214 @jhjaggars jhjaggars committed with bstansberry Dec 5, 2012
@@ -36,7 +36,15 @@
private final String[] tokens;
- public WildcardPattern(final String pattern){
+ public WildcardPattern(String pattern){
+ if (pattern.startsWith("?")) {
+ throw new IllegalArgumentException("Patterns may not start with ?");
+ }
+
+ if (!pattern.startsWith("*")) {
+ pattern = "*" + pattern;
+ }
+
StringTokenizer st = new StringTokenizer(pattern, WILDCARDS, true);
List<String> t = new ArrayList<String>();
while(st.hasMoreTokens()){
@@ -122,19 +122,10 @@ public void testWildcardFilterMiddleGlob() throws Exception {
assertFalse(filter.accepts(bad2));
}
- @Test
+ @Test(expected=IllegalArgumentException.class)
public void testWildcardFilterPrefixSingle() throws Exception {
VirtualFileFilter filter = Filters.wildcard("?this/is/a/test.txt");
- VirtualFile good = VFS.getChild("/this/is/a/test.txt");
- VirtualFile bad = VFS.getChild("/that/is/a/test.txt");
- assertTrue(filter.accepts(good));
- assertFalse(filter.accepts(bad));
-
VirtualFileFilter filter2 = Filters.wildcard("?????/is/a/test.txt");
- VirtualFile good2 = VFS.getChild("/this/is/a/test.txt");
- VirtualFile bad2 = VFS.getChild("/this/was/a/test.txt");
- assertTrue(filter2.accepts(good2));
- assertFalse(filter2.accepts(bad2));
}
@Test

0 comments on commit 88d759b

Please sign in to comment.