else
rtn=array=new ArrayImpl();
if(!directory.exists()){
if(directory instanceof FileResource) return rtn;
throw new ApplicationException("directory ["+directory.toString()+"] doesn't exist");
}
if(!directory.isDirectory()){
if(directory instanceof FileResource) return rtn;
throw new ApplicationException("file ["+directory.toString()+"] exists, but isn't a directory");
}
if(!directory.isReadable()){
if(directory instanceof FileResource) return rtn;
throw new ApplicationException("no access to read directory ["+directory.toString()+"]");
}
long startNS=System.nanoTime();
try {
// Query All
if(listInfo==LIST_INFO_QUERY_ALL)
_fillQueryAll(query,directory,filter,0,hasMeta,recurse);
// Query Name
else if(listInfo==LIST_INFO_QUERY_NAME) {
if(recurse || type!=TYPE_ALL)_fillQueryNamesRec("",query, directory, filter, 0,recurse);
else _fillQueryNames(query, directory, nameFilter, 0);
}
//Array Name/Path
else if(listInfo==LIST_INFO_ARRAY_NAME || listInfo==LIST_INFO_ARRAY_PATH) {
boolean onlyName=listInfo==LIST_INFO_ARRAY_NAME;
if(!onlyName || recurse || type!=TYPE_ALL)_fillArrayPathOrName(array, directory, nameFilter, 0, recurse, onlyName);//QueryNamesRec("",query, directory, filter, 0,recurse);
else _fillArrayName(array, directory, nameFilter, 0);
}
} catch (IOException e) {
throw Caster.toPageException(e);
}
// sort
if(sort!=null && query!=null) {
String[] arr=sort.toLowerCase().split(",");
for(int i=arr.length-1;i>=0;i--) {
try {
String[] col=arr[i].trim().split("\\s+");
if(col.length==1)query.sort(col[0].trim());
else if(col.length==2) {
String order=col[1].toLowerCase().trim();
if(order.equals("asc"))
query.sort(col[0],railo.runtime.type.Query.ORDER_ASC);
else if(order.equals("desc"))
query.sort(col[0],railo.runtime.type.Query.ORDER_DESC);
else
throw new ApplicationException("invalid order type ["+col[1]+"]");
}
}
catch(Throwable t) {}
}
}