String[] cols = new String[]{"attributes","isdirectory","lastmodified","length","mode","name",
"path","url","type","raw"};
String[] types = new String[]{"VARCHAR","BOOLEAN","DATE","DOUBLE","VARCHAR","VARCHAR",
"VARCHAR","VARCHAR","VARCHAR","VARCHAR"};
railo.runtime.type.Query query=new QueryImpl(cols,types,0,"query");
// translate directory path for display
if(directory.length()==0)directory="/";
else if(directory.startsWith("./"))directory=directory.substring(1);
else if(directory.charAt(0)!='/')directory='/'+directory;
if(directory.charAt(directory.length()-1)!='/')directory=directory+'/';
pageContext.setVariable(name,query);
int row=0;
for(int i=0;i<files.length;i++) {
FTPFile file = files[i];
if(file.getName().equals(".") || file.getName().equals("..")) continue;
query.addRow();
row++;
query.setAt("attributes",row,"");
query.setAt("isdirectory",row,Caster.toBoolean(file.isDirectory()));
query.setAt("lastmodified",row,new DateTimeImpl(file.getTimestamp()));
query.setAt("length",row,Caster.toDouble(file.getSize()));
query.setAt("mode",row,FTPConstant.getPermissionASInteger(file));
query.setAt("type",row,FTPConstant.getTypeAsString(file.getType()));
//query.setAt("permission",row,FTPConstant.getPermissionASInteger(file));
query.setAt("raw",row,file.getRawListing());
query.setAt("name",row,file.getName());
query.setAt("path",row,directory+file.getName());
query.setAt("url",row,"ftp://"+client.getRemoteAddress().getHostName()+""+directory+file.getName());
}
writeCfftp(client);
return client;
}