tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util WARUtil.java
Date Mon, 01 Nov 1999 21:52:54 GMT
costin      99/11/01 13:52:54

  Modified:    src/share/org/apache/tomcat/util WARUtil.java
  Log:
  Fix from matt@arcticmail.com.
  
  Added warning for un-war errors.
  
  Submitted by:   "Matt Petteys" <matt@arcticmail.com>
  Reviewed by:	costin@eng.sun.com
  
  Revision  Changes    Path
  1.2       +27 -15    jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java
  
  Index: WARUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WARUtil.java	1999/10/09 00:20:56	1.1
  +++ WARUtil.java	1999/11/01 21:52:52	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v 1.1
1999/10/09 00:20:56 duncan Exp $
  - * $Revision: 1.1 $
  - * $Date: 1999/10/09 00:20:56 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/WARUtil.java,v 1.2
1999/11/01 21:52:52 costin Exp $
  + * $Revision: 1.2 $
  + * $Date: 1999/11/01 21:52:52 $
    *
    * ====================================================================
    *
  @@ -71,6 +71,7 @@
   import java.net.URL;
   import java.io.IOException;
   import java.net.MalformedURLException;
  +import java.io.FileNotFoundException;
   
   /**
    *
  @@ -78,6 +79,12 @@
    */
   
   public class WARUtil {
  +    /** Expand a WAR/Jar file in a directory.
  +     *  @param dir destination directory
  +     *  @param war URL for the source WAR/JAR/ZIP file. Starting
  +     *         and ending "/" will be removed
  +     *
  +     */ 
       public static void expand(File dir, URL war)
       throws MalformedURLException, IOException {
           String s = trim(war.getFile(), "/");
  @@ -86,20 +93,25 @@
   	ZipEntry ze = null;
   
   	while ((ze = zis.getNextEntry()) != null) {
  -            File f = new File(dir, ze.getName());
  +            try {
  +		File f = new File(dir, ze.getName());
   
  -            if (ze.isDirectory()) {
  -                f.mkdirs(); 
  -	    } else {
  -	        byte[] buffer = new byte[1024];
  -		int length = 0;
  -	        FileOutputStream fos = new FileOutputStream(f);
  -
  -		while ((length = zis.read(buffer)) >= 0) {
  -		    fos.write(buffer, 0, length);
  +		if (ze.isDirectory()) {
  +		    f.mkdirs(); 
  +		} else {
  +		    byte[] buffer = new byte[1024];
  +		    int length = 0;
  +		    FileOutputStream fos = new FileOutputStream(f);
  +		    
  +		    while ((length = zis.read(buffer)) >= 0) {
  +			fos.write(buffer, 0, length);
  +		    }
  +		    
  +		    fos.close();
   		}
  -
  -		fos.close();
  +	    } catch( FileNotFoundException ex ) {
  +		// XXX replace with a call to log() when available
  +		System.out.println("WARUtil: FileNotFoundException: " +  ze.getName() + " / " + s );
   	    }
   	}
   
  
  
  

Mime
View raw message