ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Expand.java
Date Sat, 08 Jul 2000 02:58:39 GMT
conor       00/07/07 19:58:39

  Modified:    src/main/org/apache/tools/ant/taskdefs Expand.java
  Log:
  Close ZIP files after expand operation is complete.
  
  Revision  Changes    Path
  1.6       +17 -8     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Expand.java	2000/07/06 16:48:14	1.5
  +++ Expand.java	2000/07/08 02:58:38	1.6
  @@ -76,19 +76,21 @@
       public void execute() throws BuildException {
           Touch touch = (Touch) project.createTask("touch");
           touch.setTarget(target);
  -                    
  +        
  +        File srcF=project.resolveFile(source);
  +        File dir=project.resolveFile(dest);
  +        
  +        ZipInputStream zis = null;
   	try {
  -	    File srcF=project.resolveFile(source);
  -	    File dir=project.resolveFile(dest);
   	    
   	    log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
   	    // code from WarExpand
  -	    ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF));
  +	    zis = new ZipInputStream(new FileInputStream(srcF));
   	    ZipEntry ze = null;
   	    
   	    while ((ze = zis.getNextEntry()) != null) {
  +		File f = new File(dir, project.translatePath(ze.getName()));
   		try {
  -		    File f = new File(dir, project.translatePath(ze.getName()));
   		    log("expand-file " + ze.getName() , Project.MSG_VERBOSE );
   		    // create intermediary directories - sometimes zip don't add them
   		    File dirF=new File(f.getParent());
  @@ -115,12 +117,19 @@
                       }
   
   		} catch( FileNotFoundException ex ) {
  -		    System.out.println("FileNotFoundException: " +  ze.getName()  );
  +		    log("Unable to expand to file " + f.getPath(), Project.MSG_WARN);
   		}
   	    }
  -	    log("</log:expand>", Project.MSG_VERBOSE );
  +	    log("expand complete", Project.MSG_VERBOSE );
   	} catch (IOException ioe) {
  -	    ioe.printStackTrace();
  +	    throw new BuildException("Error while expanding " + srcF.getPath(), ioe);
  +	} finally {
  +	    if (zis != null) {
  +	        try {
  +	            zis.close();
  +	        }
  +	        catch (IOException e) {}
  +	    }
   	}
       }
   
  
  
  

Mime
View raw message