001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.functions.file; 020 021import lucee.commons.io.res.Resource; 022import lucee.commons.io.res.util.ResourceAndResourceNameFilter; 023import lucee.commons.io.res.util.ResourceUtil; 024import lucee.commons.io.res.util.UDFFilter; 025import lucee.commons.lang.StringUtil; 026import lucee.runtime.PageContext; 027import lucee.runtime.exp.PageException; 028import lucee.runtime.tag.Directory; 029 030public class DirectoryList { 031 032 public static Object call(PageContext pc , String path) throws PageException { 033 return call(pc, path, false, null, null, null); 034 } 035 036 public static Object call(PageContext pc , String path,boolean recurse) throws PageException { 037 return call(pc, path, recurse, null, null, null); 038 } 039 040 public static Object call(PageContext pc , String path,boolean recurse,String strListInfo) throws PageException { 041 return call(pc, path, recurse, strListInfo, null, null); 042 } 043 044 public static Object call(PageContext pc , String path,boolean recurse,String strListInfo,Object oFilter) throws PageException { 045 return call(pc, path, recurse, strListInfo, oFilter, null); 046 } 047 048 public static Object call(PageContext pc , String path,boolean recurse,String strListInfo,Object oFilter, String sort) throws PageException { 049 Resource dir=ResourceUtil.toResourceNotExisting(pc, path); 050 ResourceAndResourceNameFilter filter = UDFFilter.createResourceAndResourceNameFilter(oFilter); 051 052 int listInfo=Directory.LIST_INFO_ARRAY_PATH; 053 if(!StringUtil.isEmpty(strListInfo,true)){ 054 strListInfo=strListInfo.trim().toLowerCase(); 055 if("name".equalsIgnoreCase(strListInfo)){ 056 listInfo=Directory.LIST_INFO_ARRAY_NAME; 057 } 058 else if("query".equalsIgnoreCase(strListInfo)){ 059 listInfo=Directory.LIST_INFO_QUERY_ALL; 060 } 061 } 062 063 return Directory.actionList(pc, dir, null, Directory.TYPE_ALL, filter, filter, listInfo, recurse, sort); 064 065 066 //public static Object actionList(PageContext pageContext,Resource directory, String serverPassword, int type,ResourceFilter filter,ResourceAndResourceNameFilter nameFilter, 067 // int listInfo,boolean recurse,String sort) throws PageException { 068 069 } 070}