Package org.codehaus.plexus.archiver

Examples of org.codehaus.plexus.archiver.ResourceIterator


        if ( !checkForced() )
        {
            return;
        }

        ResourceIterator iter = getResources();
        if ( !iter.hasNext() )
        {
            throw new ArchiverException( "You must set at least one file." );
        }

        File tarFile = getDestFile();

        if ( tarFile == null )
        {
            throw new ArchiverException( "You must set the destination tar file." );
        }
        if ( tarFile.exists() && !tarFile.isFile() )
        {
            throw new ArchiverException( tarFile + " isn't a file." );
        }
        if ( tarFile.exists() && !tarFile.canWrite() )
        {
            throw new ArchiverException( tarFile + " is read-only." );
        }

        getLogger().info( "Building tar: " + tarFile.getAbsolutePath() );

        tOut = new TarOutputStream(
            compression.compress( new BufferedOutputStream( new FileOutputStream( tarFile ) ) ) );
        tOut.setDebug( true );
        if ( longFileMode.isTruncateMode() )
        {
            tOut.setLongFileMode( TarOutputStream.LONGFILE_TRUNCATE );
        }
        else if ( longFileMode.isFailMode() || longFileMode.isOmitMode() )
        {
            tOut.setLongFileMode( TarOutputStream.LONGFILE_ERROR );
        }
        else
        {
            // warn or GNU
            tOut.setLongFileMode( TarOutputStream.LONGFILE_GNU );
        }

        longWarningGiven = false;
        while ( iter.hasNext() )
        {
            ArchiveEntry entry = iter.next();
            // Check if we don't add tar file in inself
            if ( ResourceUtils.isSame( entry.getResource(), tarFile ) )
            {
                throw new ArchiverException( "A tar file cannot include itself." );
            }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.ResourceIterator

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.