use of lucee.commons.io.res.filter.ResourceFilter in project Lucee by lucee.
the class Zip method actionZip.
private void actionZip(ZipOutputStream zos, ZipParamSource zps) throws IOException, ApplicationException {
// prefix
String p = zps.getPrefix();
if (StringUtil.isEmpty(p))
p = this.prefix;
if (!StringUtil.isEmpty(p)) {
if (!StringUtil.endsWith(p, '/'))
p += "/";
} else
p = "";
if (zps.getSource().isFile()) {
String ep = zps.getEntryPath();
if (ep == null)
ep = zps.getSource().getName();
if (!StringUtil.isEmpty(p))
ep = p + ep;
add(zos, zps.getSource().getInputStream(), ep, zps.getSource().lastModified(), true);
} else {
// filter
ResourceFilter f = zps.getFilter();
if (f == null)
f = this.filter;
if (zps.isRecurse()) {
if (f != null)
f = new OrResourceFilter(new ResourceFilter[] { DirectoryResourceFilter.FILTER, f });
} else {
if (f == null)
f = FileResourceFilter.FILTER;
}
addDir(zos, zps.getSource(), p, f);
}
}
use of lucee.commons.io.res.filter.ResourceFilter in project Lucee by lucee.
the class ExportImportHandler method exportMapping.
private static List<Object> exportMapping(Mapping[] mappings, Resource dir, String pathAppendix, String filter) throws IOException {
List<Object> list = new ArrayList<Object>();
Map<String, Object> m;
for (Mapping mapping : mappings) {
MappingImpl mi = (MappingImpl) mapping;
m = new HashMap<String, Object>();
list.add(m);
m.put("virtual", mapping.getVirtual());
m.put("inspect", ConfigWebUtil.inspectTemplate(mi.getInspectTemplateRaw(), ""));
m.put("toplevel", mapping.isTopLevel());
m.put("readonly", mapping.isReadonly());
m.put("hidden", mapping.isHidden());
m.put("physicalFirst", mapping.isPhysicalFirst());
m.put("hidden", mapping.isHidden());
// archive
if (mapping.hasArchive()) {
Resource archive = mapping.getArchive();
if (archive.isFile()) {
Resource arcDir = dir.getRealResource("archive/");
arcDir.mkdir();
m.put("archive", pathAppendix + "archive/" + archive.getName());
IOUtil.copy(archive, arcDir.getRealResource(archive.getName()));
}
}
// physical
if (mapping.hasPhysical()) {
Resource physical = mi.getPhysical();
if (physical.isDirectory()) {
String id = CreateUniqueId.invoke();
Resource phyDir = dir.getRealResource("physical/" + id);
phyDir.mkdirs();
m.put("physical", pathAppendix + "physical/" + id);
ResourceFilter f = null;
if (!StringUtil.isEmpty(filter)) {
f = new OrResourceFilter(new ResourceFilter[] { new WildcardPatternFilter(filter, ","), DirectoryResourceFilter.FILTER });
}
if (// PATCH this needs more digging
!physical.getAbsolutePath().equals("/"))
ResourceUtil.copyRecursive(physical, phyDir, f);
}
}
}
return list;
}
Aggregations