Package com.github.junrar.io

Examples of com.github.junrar.io.ReadOnlyAccessFile


    logger.info(">>>>>> testing archive: "+file);
    String s = file.toString();
    s = s.substring(s.length()-3);
    if(s.equalsIgnoreCase("rar")){
      System.out.println(file.toString());
      ReadOnlyAccessFile readFile = null;
      try {
//        readFile = new ReadOnlyAccessFile(file);
        Archive arc = null;
        try {
          arc = new Archive(file);
        } catch (RarException e) {
          logger.error("archive consturctor error",e);
          errorFiles.add(file.toString());
          return;
        }
        if(arc != null){
          if(arc.isEncrypted()){
            logger.warn("archive is encrypted cannot extreact");
            unsupportedFiles.add(file.toString());
            return;
          }
          List<FileHeader> files = arc.getFileHeaders();
          for(FileHeader fh : files)
          {
            if(fh.isEncrypted()){
              logger.warn("file is encrypted cannot extract: "+fh.getFileNameString());
              unsupportedFiles.add(file.toString());
              return;
            }
            logger.info("extracting file: "+fh.getFileNameString());
            if(fh.isFileHeader() && fh.isUnicode()){
              logger.info("unicode name: "+fh.getFileNameW());
            }
            logger.info("start: "+new Date());
           
            ByteArrayOutputStream os = new ByteArrayOutputStream();
           
           
            try {
              arc.extractFile(fh, os);
            } catch (RarException e) {
              if(e.getType().equals(RarExceptionType.notImplementedYet)){
                logger.error("error extracting unsupported file: "+fh.getFileNameString(),e);
                unsupportedFiles.add(file.toString());
                return;
              }
              logger.error("error extracting file: "+fh.getFileNameString(),e);
              errorFiles.add(file.toString());
              return;
            }finally{
              os.close();
            }
           
            logger.info("end: "+new Date());
          }
        }
        logger.info("successfully tested archive: "+file);
        successfulFiles.add(file.toString());
      } catch (Exception e) {
        logger.error("file: "+file+ " extraction error - does the file exist?"+e );
        errorFiles.add(file.toString());
      } finally{
        if(readFile!=null){
          try {
            readFile.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.github.junrar.io.ReadOnlyAccessFile

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.