Package railo.commons.io.res

Examples of railo.commons.io.res.Resource


      if(res==null) return false;
      return res.exists();
    }
 
  private static boolean changed(ConfigWeb config,String jarName) {
      Resource res = _toResource(config, jarName);
      if(res==null) {
        return true;
      }
     
      try {
      URL dataUrl = toURL(config,jarName);
      boolean changed=res.length()!=HTTPUtil.length(dataUrl);
     
      return changed;
    } catch (IOException e) {
      return false;
    }
View Full Code Here


 
  private static Resource _toResource(ConfigWeb config,String jarName) {
      // destination file
    ClassLoader mainClassLoader = new TP().getClass().getClassLoader();
    try {
      Resource lib = ResourceUtil.toResourceNotExisting(config,CFMLEngineFactory.getClassLoaderRoot(mainClassLoader).getCanonicalPath());
      return lib.getRealResource(jarName);
    } catch (IOException e) {
      return null;
    }
    }
View Full Code Here

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {//if(name.indexOf("sub")!=-1)print.ds(name);
      //if(!name.endsWith("$cf")) return super.findClass(name); this break Webervices
      //File f = getFile(name.replace('.',File.separatorChar).concat(".class"));
      //print.e("directory:"+directory+"->"+name);
      Resource res=directory
      .getRealResource(
          name.replace('.','/')
          .concat(".class"));
        //File f = new File(directory,name.replace('.',File.separatorChar).concat(".class"));
        //if(f==null) throw new ClassNotFoundException("class "+name+" not found");
View Full Code Here

    @Override
    public InputStream getResourceAsStream(String name) {
        InputStream is = super.getResourceAsStream(name);
        if(is!=null) return is;
       
        Resource f = _getResource(name);
        if(f!=null)  {
            try {
                return IOUtil.toBufferedInputStream(f.getInputStream());
            }
            catch (IOException e) {}
        }
        return null;
    }
View Full Code Here

     * returns matching File Object or null if file not exust
     * @param name
     * @return matching file
     */
    public Resource _getResource(String name) {
        Resource f = directory.getRealResource(name);
        if(f!=null && f.exists() && f.isFile()) return f;
        return null;
    }
View Full Code Here

        else if(res.length()==0) {
            writeHeader=true;
        }
        // creaste new file
        else if(res.length()>maxFileSize) {
            Resource parent = res.getParentResource();
            String name = res.getName();
                       
            for(int i=maxFiles;i>0;i--) {
             
                Resource to=parent.getRealResource(name+"."+i+".bak");
                Resource from=parent.getRealResource(name+"."+(i-1)+".bak");
                if(from.exists()) {
                    if(to.exists())to.delete();
                    from.renameTo(to);
                }
            }
            res.renameTo(parent.getRealResource(name+".1.bak"));
            res=parent.getRealResource(name);//new File(parent,name);
            res.createNewFile();
View Full Code Here

        textTagLib=ConfigWebUtil.replacePlaceholder(textTagLib, config);
        // File TagLib
        String ext=ResourceUtil.getExtension(textTagLib,null);
        boolean hasTldExtension="tld".equalsIgnoreCase(ext);
       
        Resource absFile=config.getResource(textTagLib);
      // TLD
    if(absFile.isFile()) return _executeTLD(config,absFile,nameSpace,nameSpaceSeparator,cfml);
    // CTD
    //else if(absFile.isDirectory()) return _executeCTD(absFile,textPrefix);
   
       
    // Second Change     
    if(textTagLib.startsWith("/")){
            //config.getPhysical(textTagLib);
        PageSource ps = ((ConfigImpl)config).getPageSourceExisting(null,null,textTagLib,false,false,true,false);
       
        //config.getConfigDir()
        if(ps!=null) {
            if(ps.physcalExists()) {
              Resource file = ps.getPhyscalFile();
          // TLD
              if(file.isFile()) return _executeTLD(config,file,nameSpace,nameSpaceSeparator,cfml);
            }
        // CTD
        if(!hasTldExtension)return _executeCTD(textTagLib,nameSpace,nameSpaceSeparator);
        }
    }
    else {
      Resource sourceFile=cfml.getSourceFile().getPhyscalFile();
        if(sourceFile!=null) {
          Resource file = sourceFile.getParentResource().getRealResource(textTagLib);
        // TLD
            if(file.isFile()) return _executeTLD(config,file,nameSpace,nameSpaceSeparator,cfml);
        // CTD
            if(!hasTldExtension)return _executeCTD(textTagLib,nameSpace,nameSpaceSeparator);
        }
    }
      throw new TemplateException(cfml,"invalid definition of the attribute taglib ["+textTagLib+"]");
View Full Code Here

   
   

    private static void extractTGZ(Resource source, Resource target) throws IOException {
      //File tmpTarget = File.createTempFile("_temp","tmp");
      Resource tmp = SystemUtil.getTempDirectory().getRealResource(System.currentTimeMillis()+".tmp");
        try {
          // read Gzip
          extractGZip(source, tmp);
         
          // read Tar
          extractTar(tmp, target);
        }
        finally {
          tmp.delete();
        }
  }
View Full Code Here

          tis = new TarArchiveInputStream( IOUtil.toBufferedInputStream(tarFile.getInputStream()) ) ;    
          TarArchiveEntry entry;
          int mode;
          while ( ( entry = tis.getNextTarEntry()) != null ) {
            //print.ln(entry);
            Resource target=targetDir.getRealResource(entry.getName());
              if(entry.isDirectory()) {
                  target.mkdirs();
              }
              else {
                Resource parent=target.getParentResource();
                  if(!parent.exists())parent.mkdirs();
                  IOUtil.copy(tis,target,false);
              }
              target.setLastModified(entry.getModTime().getTime());
              mode=entry.getMode();
              if(mode>0)target.setMode(mode);
View Full Code Here

      ZipInputStream zis=null;
        try {
          zis = new ZipInputStream( IOUtil.toBufferedInputStream(zipFile.getInputStream()) ) ;    
          ZipEntry entry;
          while ( ( entry = zis.getNextEntry()) != null ) {
            Resource target=targetDir.getRealResource(entry.getName());
              if(entry.isDirectory()) {
                  target.mkdirs();
              }
              else {
                Resource parent=target.getParentResource();
                  if(!parent.exists())parent.mkdirs();
                  IOUtil.copy(zis,target,false);
              }
              target.setLastModified(entry.getTime());
              zis.closeEntry() ;
          }
View Full Code Here

TOP

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

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.