Search in sources :

Example 1 with ResourceNameFilter

use of lucee.commons.io.res.filter.ResourceNameFilter in project Lucee by lucee.

the class Directory method _fillArrayName.

// this method only exists for performance reasion
private static int _fillArrayName(Array arr, Resource directory, ResourceFilter filter, int count) {
    if (filter == null || filter instanceof ResourceNameFilter) {
        ResourceNameFilter rnf = filter == null ? null : (ResourceNameFilter) filter;
        String[] list = directory.list();
        if (list == null || list.length == 0)
            return count;
        for (int i = 0; i < list.length; i++) {
            if (rnf == null || rnf.accept(directory, list[i])) {
                arr.appendEL(list[i]);
            }
        }
    } else {
        Resource[] list = directory.listResources();
        if (list == null || list.length == 0)
            return count;
        for (int i = 0; i < list.length; i++) {
            if (filter.accept(list[i])) {
                arr.appendEL(list[i].getName());
            }
        }
    }
    return count;
}
Also used : Resource(lucee.commons.io.res.Resource) FileResource(lucee.commons.io.res.type.file.FileResource) ResourceNameFilter(lucee.commons.io.res.filter.ResourceNameFilter)

Example 2 with ResourceNameFilter

use of lucee.commons.io.res.filter.ResourceNameFilter in project Lucee by lucee.

the class Directory method _fillQueryNames.

// this method only exists for performance reasion
private static int _fillQueryNames(Query query, Resource directory, ResourceFilter filter, int count) throws PageException {
    if (filter == null || filter instanceof ResourceNameFilter) {
        ResourceNameFilter rnf = filter == null ? null : (ResourceNameFilter) filter;
        String[] list = directory.list();
        if (list == null || list.length == 0)
            return count;
        for (int i = 0; i < list.length; i++) {
            if (rnf == null || rnf.accept(directory, list[i])) {
                query.addRow(1);
                count++;
                query.setAt(KeyConstants._name, count, list[i]);
            }
        }
    } else {
        Resource[] list = directory.listResources();
        if (list == null || list.length == 0)
            return count;
        for (int i = 0; i < list.length; i++) {
            if (filter == null || filter.accept(list[i])) {
                query.addRow(1);
                count++;
                query.setAt(KeyConstants._name, count, list[i].getName());
            }
        }
    }
    return count;
}
Also used : Resource(lucee.commons.io.res.Resource) FileResource(lucee.commons.io.res.type.file.FileResource) ResourceNameFilter(lucee.commons.io.res.filter.ResourceNameFilter)

Aggregations

Resource (lucee.commons.io.res.Resource)2 ResourceNameFilter (lucee.commons.io.res.filter.ResourceNameFilter)2 FileResource (lucee.commons.io.res.type.file.FileResource)2