Package railo.commons.io.res

Examples of railo.commons.io.res.ResourceProvider


    /**
     * @return return System directory
     */
    public static Resource getSystemDirectory() {
        String pathes=System.getProperty("java.library.path");
        ResourceProvider fr = ResourcesImpl.getFileResourceProvider();
        if(pathes!=null) {
            String[] arr=ListUtil.toStringArrayEL(ListUtil.listToArray(pathes,File.pathSeparatorChar));
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("windows\\system")!=-1) {
                    Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("windows")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("winnt")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {   
                if(arr[i].toLowerCase().indexOf("win")!=-1) {
                  Resource file = fr.getResource(arr[i]);
                    if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
                   
                }
            }
            for(int i=0;i<arr.length;i++) {
              Resource file = fr.getResource(arr[i]);
                if(file.exists() && file.isDirectory() && file.isWriteable()) return ResourceUtil.getCanonicalResourceEL(file);
            }
        }
        return null;
    }
View Full Code Here


   
    /**
     * @return return running context root
     */
    public static Resource getRuningContextRoot() {
      ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
       
        try {
            return frp.getResource(".").getCanonicalResource();
        } catch (IOException e) {}
        URL url=new Info().getClass().getClassLoader().getResource(".");
        try {
            return frp.getResource(FileUtil.URLToFile(url).getAbsolutePath());
        } catch (MalformedURLException e) {
            return null;
        }
    }
View Full Code Here

     * returns the Temp Directory of the System
     * @return temp directory
     */
    public static Resource getTempDirectory() {
        if(tempFile!=null) return tempFile;
        ResourceProvider fr = ResourcesImpl.getFileResourceProvider();
        String tmpStr = System.getProperty("java.io.tmpdir");
        if(tmpStr!=null) {
            tempFile=fr.getResource(tmpStr);
            if(tempFile.exists()) {
                tempFile=ResourceUtil.getCanonicalResourceEL(tempFile);
                return tempFile;
            }
        }
        File tmp =null;
        try {
          tmp = File.createTempFile("a","a");
            tempFile=fr.getResource(tmp.getParent());
            tempFile=ResourceUtil.getCanonicalResourceEL(tempFile);  
        }
        catch(IOException ioe) {}
        finally {
          if(tmp!=null)tmp.delete();
View Full Code Here

     * @return home directory
     */
    public static Resource getHomeDirectory() {
        if(homeFile!=null) return homeFile;
       
        ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
       
        String homeStr = System.getProperty("user.home");
        if(homeStr!=null) {
            homeFile=frp.getResource(homeStr);
            homeFile=ResourceUtil.getCanonicalResourceEL(homeFile);
        }
        return homeFile;
    }
View Full Code Here

        ClassLoader pcl=ucl.getParent();
        // parent first
        if(pcl instanceof URLClassLoader)
            getClassPathesFromClassLoader((URLClassLoader) pcl, pathes);

        ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
        // get all pathes
        URL[] urls=ucl.getURLs();
        for(int i=0;i<urls.length;i++) {
            Resource file=frp.getResource(urls[i].getPath());
            if(file.exists())
                pathes.add(ResourceUtil.getCanonicalResourceEL(file));
        }
       
    }
View Full Code Here

        ArrayList pathes=new ArrayList();
        String pathSeperator=System.getProperty("path.separator");
        if(pathSeperator==null)pathSeperator=";";
           
    // java.ext.dirs
        ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
     
       
    // pathes from system properties
        String strPathes=System.getProperty("java.class.path");
        if(strPathes!=null) {
            Array arr=ListUtil.listToArrayRemoveEmpty(strPathes,pathSeperator);
            int len=arr.size();
            for(int i=1;i<=len;i++) {
                Resource file=frp.getResource(Caster.toString(arr.get(i,""),"").trim());
                if(file.exists())
                    pathes.add(ResourceUtil.getCanonicalResourceEL(file));
            }
        }
       
View Full Code Here

        }
        return parsePlaceHolder(path, sc);
    }
   
  public static String parsePlaceHolder(String path, ServletContext sc) {
      ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
     
     
        if(path==null) return null;
        if(path.indexOf('{')!=-1){
          if(StringUtil.startsWith(path,'{')){
             
              // Web Root
              if(path.startsWith("{web-root")) {
                  if(path.startsWith("}",9))           path=frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(10)).toString();
                  else if(path.startsWith("-dir}",9))     path=frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(14)).toString();
                  else if(path.startsWith("-directory}",9))   path=frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(20)).toString();
 
              }
              else path=SystemUtil.parsePlaceHolder(path);
          }
         
View Full Code Here

            compressTar(parent, source.listResources(),tos,mode);
        }
    }

    public static void main(String[] args) throws IOException {
      ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
      Resource src = frp.getResource("/Users/mic/temp/a");
     
      Resource tgz = frp.getResource("/Users/mic/temp/b/a.tgz");
      tgz.getParentResource().mkdirs();
      Resource tar = frp.getResource("/Users/mic/temp/b/a.tar");
      tar.getParentResource().mkdirs();
      Resource zip = frp.getResource("/Users/mic/temp/b/a.zip");
      zip.getParentResource().mkdirs();
     
      Resource tgz1 = frp.getResource("/Users/mic/temp/b/tgz");
      tgz1.mkdirs();
      Resource tar1 = frp.getResource("/Users/mic/temp/b/tar");
      tar1.mkdirs();
      Resource zip1 = frp.getResource("/Users/mic/temp/b/zip");
      zip1.mkdirs();
     
      compressTGZ(new Resource[]{src}, tgz, -1);
      compressTar(new Resource[]{src}, tar, -1);
      compressZip(new Resource[]{src}, zip, null);
View Full Code Here

import railo.commons.io.res.ResourceProvider;
import railo.commons.io.res.ResourcesImpl;

public class RemoveLN {
  public static void main(String[] args) throws IOException {
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
    Resource res = frp.getResource("/Users/mic/Projects/Railo/Source/railo/railo-java/railo-core/src/railo/commons/util/mod/SyncMap");
    BufferedReader r = IOUtil.toBufferedReader(IOUtil.getReader(res, (Charset)null));
    String line;
    StringBuilder sb=new StringBuilder();
    while((line=r.readLine())!=null){
      sb.append(line.substring(5));
View Full Code Here

        // check parameters
        Element parent=_getRootElement("resources");
        Element[] elProviders = ConfigWebFactory.getChildren(parent,"resource-provider");
        Element[] elDefaultProviders = ConfigWebFactory.getChildren(parent,"default-resource-provider");
        ResourceProvider[] providers = config.getResourceProviders();
        ResourceProvider defaultProvider = config.getDefaultResourceProvider();
   
        Query qry=new QueryImpl(new String[]{"support","scheme","caseSensitive","default","class","arguments"},elProviders.length+elDefaultProviders.length,"resourceproviders");
        int row=1;
        for(int i=0;i<elDefaultProviders.length;i++) {
          getResourceProviders(new ResourceProvider[]{defaultProvider},qry,elDefaultProviders[i],row++,Boolean.TRUE);
View Full Code Here

TOP

Related Classes of railo.commons.io.res.ResourceProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.