use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class CollectFiles method execute.
@Override
public void execute() throws Exception {
VirtualFile root = VFS.getChild(this.env.getJbossHome());
List<VirtualFile> matches = root.getChildrenRecursively(Filters.and(this.filter, this.blacklistFilter));
// get some limit on that set, which probably would be wrong.
if (sorter != null) {
Collections.sort(matches, sorter);
}
// limit how much data we collect
Limiter limiter = new Limiter(limit);
Iterator<VirtualFile> iter = matches.iterator();
while (iter.hasNext() && !limiter.isDone()) {
VirtualFile f = iter.next();
InputStream stream = limiter.limit(f);
for (Sanitizer sanitizer : this.sanitizers) {
if (sanitizer.accepts(f)) {
stream = sanitizer.sanitize(stream);
}
}
this.env.getZip().add(f, stream);
Utils.safelyClose(stream);
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class JdrTestCase method testWildcardFilterPrefixGlob.
@Test
public void testWildcardFilterPrefixGlob() throws Exception {
VirtualFileFilter filter = Filters.wildcard("*.txt");
VirtualFile good = VFS.getChild("/this/is/a/test.txt");
VirtualFile bad = VFS.getChild("/this/is/a/test.xml");
VirtualFile wingood = VFS.getChild("/C:/this/is/a/test.txt");
VirtualFile winbad = VFS.getChild("/C:/this/is/a/test.xml");
assertTrue(filter.accepts(good));
assertFalse(filter.accepts(bad));
assertTrue(filter.accepts(wingood));
assertFalse(filter.accepts(winbad));
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class JdrTestCase method testWildcardFilterAcceptAnything.
@Test
public void testWildcardFilterAcceptAnything() throws Exception {
VirtualFileFilter filter = Filters.wildcard("*");
VirtualFile good = VFS.getChild("/this/is/a/test.txt");
assertTrue(filter.accepts(good));
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class JdrTestCase method testWildcardFilterMiddleGlob.
@Test
public void testWildcardFilterMiddleGlob() throws Exception {
VirtualFileFilter filter = Filters.wildcard("/this*test.txt");
VirtualFile good = VFS.getChild("/this/is/a/test.txt");
VirtualFile bad1 = VFS.getChild("/that/is/a/test.txt");
VirtualFile bad2 = VFS.getChild("/this/is/a/test.xml");
VirtualFile win = VFS.getChild("/C:/this/is/a/test.txt");
VirtualFile winbad = VFS.getChild("/C:/this/is/a/test.xml");
assertTrue(filter.accepts(good));
assertTrue(filter.accepts(win));
assertFalse(filter.accepts(bad1));
assertFalse(filter.accepts(bad2));
assertFalse(filter.accepts(winbad));
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class HibernateAnnotationScanner method toNIS.
private Set<NamedInputStream> toNIS(Iterable<VirtualFile> files) {
Set<NamedInputStream> result = new HashSet<NamedInputStream>();
for (VirtualFile file : files) {
NamedInputStream nis = new HibernateVirtualFileNamedInputStream(file);
result.add(nis);
}
return result;
}
Aggregations