use of lucee.commons.io.res.util.ModeObjectWrap in project Lucee by lucee.
the class Directory method _fillQueryAll.
private static int _fillQueryAll(Query query, Resource directory, ResourceFilter filter, int count, boolean hasMeta, boolean recurse) throws PageException, IOException {
Resource[] list = directory.listResources();
if (list == null || list.length == 0)
return count;
String dir = directory.getCanonicalPath();
// fill data to query
// query.addRow(list.length);
boolean isDir;
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());
isDir = list[i].isDirectory();
query.setAt(KeyConstants._size, count, new Double(isDir ? 0 : list[i].length()));
query.setAt(KeyConstants._type, count, isDir ? "Dir" : "File");
if (directory.getResourceProvider().isModeSupported()) {
query.setAt(MODE, count, new ModeObjectWrap(list[i]));
}
query.setAt(DATE_LAST_MODIFIED, count, new Date(list[i].lastModified()));
query.setAt(ATTRIBUTES, count, getFileAttribute(list[i], true));
if (hasMeta) {
query.setAt(META, count, ((ResourceMetaData) list[i]).getMetaData());
}
query.setAt(DIRECTORY, count, dir);
}
if (recurse && list[i].isDirectory())
count = _fillQueryAll(query, list[i], filter, count, hasMeta, recurse);
}
return count;
}
use of lucee.commons.io.res.util.ModeObjectWrap in project Lucee by lucee.
the class FileTag method getInfo.
public static Struct getInfo(PageContext pc, Resource file, String serverPassword) throws PageException {
SecurityManager sm = pc.getConfig().getSecurityManager();
checkFile(pc, sm, file, serverPassword, false, false, false, false);
Struct sct = new StructImpl();
// fill data to query
sct.setEL(KeyConstants._name, file.getName());
sct.setEL(KeyConstants._size, Long.valueOf(file.length()));
sct.setEL(KeyConstants._type, file.isDirectory() ? "Dir" : "File");
sct.setEL("dateLastModified", new DateTimeImpl(pc, file.lastModified(), false));
sct.setEL("attributes", getFileAttribute(file));
if (SystemUtil.isUnix())
sct.setEL(KeyConstants._mode, new ModeObjectWrap(file));
try {
sct.setEL(KeyConstants._checksum, Hash.md5(file));
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
BufferedImage bi = ImageUtil.toBufferedImage(file, null);
if (bi != null) {
Struct img = new StructImpl();
img.setEL(KeyConstants._width, new Double(bi.getWidth()));
img.setEL(KeyConstants._height, new Double(bi.getHeight()));
sct.setEL(KeyConstants._img, img);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
return sct;
}
Aggregations