use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class ComponentListPackage method _listArchive.
private static String[] _listArchive(PageContext pc, String path, Mapping mapping) throws IOException {
String packageName = StringUtil.replace(path, File.separator, ".", false);
Resource archive = mapping.getArchive();
if (archive != null) {
// TODO nor working with pathes with none ascci characters, eith none ascci characters, the java class path is renamed, so make sure you rename the path as well
String strDir = "zip://" + archive + "!" + File.separator + path;
Resource dir = ResourceUtil.toResourceNotExisting(pc, strDir, true, false);
if (dir.isDirectory()) {
java.util.List<String> list = new ArrayList<String>();
// we use the class files here to get the info, the source files are optional and perhaps not present.
Resource[] children = dir.listResources(FILTER_CLASS);
String className, c, sourceName = null;
for (int i = 0; i < children.length; i++) {
className = children[i].getName();
className = className.substring(0, className.length() - 6);
className = packageName + "." + className;
try {
Class<?> clazz = mapping.getArchiveClass(className);
sourceName = ASMUtil.getSourceInfo(pc.getConfig(), clazz, true).name;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (StringUtil.isEmpty(sourceName)) {
c = IOUtil.toString(children[i], (Charset) null);
int loc = c.indexOf("<clinit>");
if (loc != -1) {
c = c.substring(0, loc);
c = ListUtil.last(c, "/\\", true).trim();
if (Constants.isComponentExtension(ResourceUtil.getExtension(c, "")))
list.add(c);
}
} else
list.add(sourceName);
}
if (list.size() > 0)
return list.toArray(new String[list.size()]);
}
}
return null;
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class DirectoryCreate method call.
public static String call(PageContext pc, String path, boolean createPath, boolean ignoreExists) throws PageException {
Resource dir = ResourceUtil.toResourceNotExisting(pc, path);
Directory.actionCreate(pc, dir, null, createPath, -1, null, null, ignoreExists ? FileUtil.NAMECONFLICT_SKIP : FileUtil.NAMECONFLICT_ERROR);
return null;
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class DirectoryList method _call.
public static Object _call(PageContext pc, String path, boolean recurse, int listInfo, Object oFilter, String sort, int type) throws PageException {
Resource dir = ResourceUtil.toResourceNotExisting(pc, path);
ResourceFilter filter = UDFFilter.createResourceAndResourceNameFilter(oFilter);
return Directory.actionList(pc, dir, null, type, filter, listInfo, recurse, sort);
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class FileExists method call.
public static boolean call(PageContext pc, Object obj, Object oAllowRealPath) throws PageException {
if (oAllowRealPath == null)
return call(pc, obj);
Resource res = Caster.toResource(pc, obj, false, Caster.toBooleanValue(oAllowRealPath));
if (res == null)
return false;
pc.getConfig().getSecurityManager().checkFileLocation(res);
return res.isFile();
}
use of lucee.commons.io.res.Resource in project Lucee by lucee.
the class FileGetMimeType method call.
public static String call(PageContext pc, Object oSrc, boolean checkHeader) throws PageException {
Resource src = Caster.toResource(pc, oSrc, false);
pc.getConfig().getSecurityManager().checkFileLocation(src);
String mimeType = ResourceUtil.getMimeType(src, null);
if (StringUtil.isEmpty(mimeType, true))
return "application/octet-stream";
return mimeType;
}
Aggregations