Package com.ice.tar

Examples of com.ice.tar.TarEntry


    TarInputStream tin = new TarInputStream( new GZIPInputStream(new FileInputStream(new File(tarFileName))));

    //get the first entry in the archive

    TarEntry tarEntry = tin.getNextEntry();

    while (tarEntry != null)
    { 
      //create a file with the same name as the tarEntry

      File destPath = new File(destination + File.separatorChar + tarEntry.getName());

      if (tarEntry.isDirectory())
      {
        destPath.mkdir();
      }
      else
      {
View Full Code Here


    FileInputStream fileStream = new FileInputStream( file );
    try {
      // create a zip input stream from the tmp file that was uploaded
      TarInputStream zipStream = new TarInputStream( new BufferedInputStream( fileStream ) );
      try {
        TarEntry entry = zipStream.getNextEntry();
        // iterate thru the entries in the zip file
        while ( entry != null ) {
          // ignore hidden directories and files, extract the rest
          if ( !entry.isDirectory() && !entry.getName().startsWith( "." ) && !entry.getName().startsWith( "__MACOSX/" ) ) { //$NON-NLS-1$ //$NON-NLS-2$
            File entryFile = null;
            if ( isTemporary() ) {
              String extension = ".tmp"; //$NON-NLS-1$
              int idx = entry.getName().lastIndexOf( '.' );
              if ( idx != -1 ) {
                extension = entry.getName().substring( idx ) + extension;
              }
              entryFile = PentahoSystem.getApplicationContext().createTempFile( session, "", extension, true ); //$NON-NLS-1$
            } else {
              entryFile = new File( getPath() + File.separatorChar + entry.getName() );
            }

            if ( sb.length() > 0 ) {
              sb.append( "\n" ); //$NON-NLS-1$
            }
View Full Code Here

    }
    protected void extractAndIndexTarFile(InputStream is, Document doc, TempFiles tempFiles, Charset charset ) {
      logger.debug("extractAndIndexTarFile()");
      try {
        TarInputStream gis = new TarInputStream(is);
        TarEntry entry;
        while((entry = gis.getNextEntry()) != null) {
                 String name = entry.getName();
                 int dot = name.lastIndexOf('.');
                 if (dot==-1) continue;
                 String extention = name.substring(dot+1,name.length());
                 Reader textReader = Extractor.getText(gis,extention,tempFiles,charset);
                   if (textReader!=null) {
View Full Code Here

     */
    private int unZapTarFile(File fileToUnzap, String fileToUnzapLowerCase) {

        InputStream is  = null;
        TarInputStream tis = null;
        TarEntry tarEntry = null;
        boolean entryFound = false;
        boolean nonDirectoryEntryFound = false;
        int numberEntriesExtracted = 0;
        try {
            is  = new FileInputStream(fileToUnzap);

            // If the tar file ends with a Gzip extension, use the GZIP filter.
            if ( fileToUnzapLowerCase.endsWith(this.tarGzipExtension) ||
                 fileToUnzapLowerCase.endsWith(this.tarGzipExtensionAlt1) ||
                 fileToUnzapLowerCase.endsWith(this.tarGzipExtensionAlt2) ) {
                is = new GZIPInputStream(is);
            }

            tis = new TarInputStream(is);
            String fileName = null;

            // Loop through all the tar entries.
            tarEntry = tis.getNextEntry();
            while (tarEntry != null) {

                entryFound = true;

                // Skip over directories
                if (!tarEntry.isDirectory()) {

                    nonDirectoryEntryFound = true;

                    // Should this file be should extracted?
                    if (this.nameSelector.isIncluded(tarEntry.getName())) {

                        fileName = makeOutputFileName(tarEntry.getName(), fileToUnzap.getName());

                        writeNextTarEntry(tis,
                                new File(this.destLocationFile, fileName));

                        numberEntriesExtracted++;
View Full Code Here

                super.currentObjBeingProcessed = selectedFile;

                // Instance variable used so the "cleanUp()" method can
                // close this stream.
                this.inStream = new FileInputStream(selectedFile);
                TarEntry tarEntry = null;
                try {
                    tarEntry = new TarEntry(selectedFile, selectedFile.getName());
                } catch (InvalidHeaderException e) {
                    errEntry.setThrowable(e);
                    errEntry.setAppContext("tar()");
                    errEntry.setAppMessage("Error tar'ing: " + selectedFile);
                    logger.logError(errEntry);
View Full Code Here

    for (File file : files)
    {
      if (!file.isDirectory())
      {
        // make regular entry
        TarEntry entry = new TarEntry(file);
        if (unixArchiveFormat)
        {
          entry.setUnixTarFormat();
        }
        else
        {
          entry.setUSTarFormat();
        }
        // FIXME: index -1 wanneer verkeerde file sep!
        entry.setName(entry.getName().substring(entry.getName().lastIndexOf("/") + 1, entry.getName().length()));

        // add to tar. just a file, no need for recursion ('false')
        archive.writeEntry(entry, false);

      }
      else
      {
        // entry is a directory, so tar the content :)
        TarEntry entry = new TarEntry(TarGz.tarDir(file));

        if (unixArchiveFormat)
        {
          entry.setUnixTarFormat();
        }
        else
        {
          entry.setUSTarFormat();
        }
        // FIXME: index -1 wanneer verkeerde file sep!
        entry.setName(entry.getName().substring(entry.getName().lastIndexOf("/") + 1, entry.getName().length()));

        // write entry (now a tar) to tar
        archive.writeEntry(entry, false);
      }
    }
View Full Code Here

    }
    protected void extractAndIndexTarFile(InputStream is, Document doc, TempFiles tempFiles ) {
      logger.debug("extractAndIndexTarFile()");
      try {
        TarInputStream gis = new TarInputStream(is);
        TarEntry entry;
        while((entry = gis.getNextEntry()) != null) {
                 String name = entry.getName();
                 int dot = name.lastIndexOf('.');
                 if (dot==-1) continue;
                 String extention = name.substring(dot+1,name.length());
                 try {
                    Reader textReader = Extractor.getText(gis,extention,tempFiles);
View Full Code Here

   */
  private static void untar( String filename, String outputDirectory ) throws IOException
  {
    System.out.println( "Reading TarInputStream... (using classes from http://www.trustice.com/java/tar/)" );
    TarInputStream tin = new TarInputStream( getInputStream( filename ) );
    TarEntry tarEntry = tin.getNextEntry();
//    if( new File( outputDirectory ).exists() )
//    {
      while( tarEntry != null )
      {
        File destPath = new File( outputDirectory + File.separator + tarEntry.getName() );
        System.out.println( "Processing " + destPath.getAbsoluteFile() );
        if( !tarEntry.isDirectory() )
        {
          FileOutputStream fout = new FileOutputStream( destPath );
          tin.copyEntryContents( fout );
          fout.close();
        }
View Full Code Here

TOP

Related Classes of com.ice.tar.TarEntry

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.