ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive Untar.java Expand.java
Date Sun, 27 Jan 2002 10:28:35 GMT
donaldp     02/01/27 02:28:35

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive
                        Untar.java Expand.java
  Log:
  Cleanup the expand related classes a lil more
  
  Revision  Changes    Path
  1.3       +1 -7      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java
  
  Index: Untar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Untar.java	27 Jan 2002 10:23:36 -0000	1.2
  +++ Untar.java	27 Jan 2002 10:28:35 -0000	1.3
  @@ -24,15 +24,9 @@
   public class Untar
       extends Expand
   {
  -    protected void expandFile( final File src, final File dir )
  +    protected void expandArchive( final File src, final File dir )
           throws TaskException
       {
  -        if( getLogger().isInfoEnabled() )
  -        {
  -            final String message = "Expanding: " + src + " into " + dir;
  -            getLogger().info( message );
  -        }
  -
           TarInputStream input = null;
           FileInputStream fileInput = null;
           try
  
  
  
  1.3       +38 -21    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Expand.java	27 Jan 2002 10:23:36 -0000	1.2
  +++ Expand.java	27 Jan 2002 10:28:35 -0000	1.3
  @@ -165,6 +165,24 @@
       protected void expandFile( final File src, final File dir )
           throws TaskException
       {
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            final String message = "Expanding: " + src + " into " + dir;
  +            getLogger().info( message );
  +        }
  +
  +        expandArchive( src, dir );
  +
  +        if( getLogger().isDebugEnabled() )
  +        {
  +            final String message = "expand complete";
  +            getLogger().debug( message );
  +        }
  +    }
  +
  +    protected void expandArchive( final File src, final File dir )
  +        throws TaskException
  +    {
           ZipInputStream zis = null;
           try
           {
  @@ -175,12 +193,11 @@
               while( ( ze = zis.getNextEntry() ) != null )
               {
                   final Date date = new Date( ze.getTime() );
  -                extractFile(
  -                    dir,
  -                    zis,
  -                    ze.getName(),
  -                    date,
  -                    ze.isDirectory() );
  +                extractFile( dir,
  +                             zis,
  +                             ze.getName(),
  +                             date,
  +                             ze.isDirectory() );
               }
           }
           catch( final IOException ioe )
  @@ -192,9 +209,6 @@
           {
               IOUtil.shutdownStream( zis );
           }
  -
  -        final String message = "expand complete";
  -        getLogger().debug( message );
       }
   
       protected void extractFile( final File dir,
  @@ -249,31 +263,33 @@
               }
           }
   
  -        File f = FileUtil.resolveFile( dir, entryName );
  +        final File file = FileUtil.resolveFile( dir, entryName );
           try
           {
  -            if( !m_overwrite && f.exists()
  -                && f.lastModified() >= date.getTime() )
  +            if( !m_overwrite && file.exists() &&
  +                file.lastModified() >= date.getTime() )
               {
  -                getLogger().debug( "Skipping " + f + " as it is up-to-date" );
  +                final String message = "Skipping " + file + " as it is up-to-date";
  +                getLogger().debug( message );
                   return;
               }
   
  -            getLogger().debug( "expanding " + entryName + " to " + f );
  +            getLogger().debug( "expanding " + entryName + " to " + file );
  +
               // create intermediary directories - sometimes zip don't add them
  -            File dirF = f.getParentFile();
  -            dirF.mkdirs();
  +            final File parent = file.getParentFile();
  +            parent.mkdirs();
   
               if( isDirectory )
               {
  -                f.mkdirs();
  +                file.mkdirs();
               }
               else
               {
                   FileOutputStream fos = null;
                   try
                   {
  -                    fos = new FileOutputStream( f );
  +                    fos = new FileOutputStream( file );
                       IOUtil.copy( input, fos );
                   }
                   finally
  @@ -282,11 +298,12 @@
                   }
               }
   
  -            f.setLastModified( date.getTime() );
  +            file.setLastModified( date.getTime() );
           }
  -        catch( FileNotFoundException ex )
  +        catch( final FileNotFoundException fnfe )
           {
  -            getLogger().warn( "Unable to expand to file " + f.getPath() );
  +            final String message = "Unable to expand to file " + file.getPath();
  +            getLogger().warn( message );
           }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message