001 package railo.runtime.functions.file; 002 003 import java.io.IOException; 004 005 import railo.commons.io.res.Resource; 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.FunctionException; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.op.Caster; 010 011 public class FileDelete { 012 013 public static String call(PageContext pc, Object oSrc) throws PageException { 014 Resource src = Caster.toResource(oSrc,false); 015 016 pc.getConfig().getSecurityManager().checkFileLocation(src); 017 if(!src.exists()) 018 throw new FunctionException(pc,"FileDelete",1,"source", 019 "source file ["+src+"] does not exists"); 020 try { 021 src.remove(false); 022 } catch (IOException e) { 023 throw Caster.toPageException(e); 024 } 025 return null; 026 } 027 }