Search in sources :

Example 1 with JarResource

use of com.eden.orchid.api.resources.resource.JarResource in project Orchid by JavaEden.

the class DefaultResourceSource method getResourceEntries.

@Override
public List<OrchidResource> getResourceEntries(String path, String[] fileExtensions, boolean recursive) {
    List<OrchidResource> entries = new ArrayList<>();
    JarFile jarFile = jarForClass(this.getClass());
    if (jarFile == null) {
        return entries;
    }
    Enumeration<JarEntry> jarEntries = jarFile.entries();
    while (jarEntries.hasMoreElements()) {
        JarEntry jarEntry = jarEntries.nextElement();
        // we are checking a file in the jar
        if (OrchidUtils.normalizePath(jarEntry.getName()).startsWith(path + "/") && !jarEntry.isDirectory()) {
            if (EdenUtils.isEmpty(fileExtensions) || FilenameUtils.isExtension(jarEntry.getName(), fileExtensions)) {
                if (shouldAddEntry(jarEntry.getName())) {
                    entries.add(new JarResource(context, jarFile, jarEntry));
                }
            }
        }
    }
    return entries;
}
Also used : JarResource(com.eden.orchid.api.resources.resource.JarResource) OrchidResource(com.eden.orchid.api.resources.resource.OrchidResource) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry)

Aggregations

JarResource (com.eden.orchid.api.resources.resource.JarResource)1 OrchidResource (com.eden.orchid.api.resources.resource.OrchidResource)1 ArrayList (java.util.ArrayList)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1