Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 12118 invoked from network); 28 Feb 2002 07:04:53 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 28 Feb 2002 07:04:53 -0000 Received: (qmail 14508 invoked by uid 97); 28 Feb 2002 07:04:51 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 14492 invoked by uid 97); 28 Feb 2002 07:04:50 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 14481 invoked by uid 97); 28 Feb 2002 07:04:50 -0000 Date: 28 Feb 2002 07:04:37 -0000 Message-ID: <20020228070437.20452.qmail@icarus.apache.org> From: patrickl@apache.org To: jakarta-tomcat-4.0-cvs@apache.org Subject: cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources WARDirContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N patrickl 02/02/27 23:04:37 Modified: catalina/src/share/org/apache/naming/resources WARDirContext.java Log: Fix to handle war files that do not have separate ZipEntry objects for directories. Surprisingly, this is a valid format for a jar file. This fix emulates the functionality the JDK's jar command provides when unpacking jar files with missing directory entries. Revision Changes Path 1.5 +30 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/WARDirContext.java Index: WARDirContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/WARDirContext.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WARDirContext.java 27 Feb 2002 01:17:00 -0000 1.4 +++ WARDirContext.java 28 Feb 2002 07:04:36 -0000 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/WARDirContext.java,v 1.4 2002/02/27 01:17:00 craigmcc Exp $ - * $Revision: 1.4 $ - * $Date: 2002/02/27 01:17:00 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/WARDirContext.java,v 1.5 2002/02/28 07:04:36 patrickl Exp $ + * $Revision: 1.5 $ + * $Date: 2002/02/28 07:04:36 $ * * ==================================================================== * @@ -100,7 +100,7 @@ * WAR Directory Context implementation. * * @author Remy Maucherat - * @version $Revision: 1.4 $ $Date: 2002/02/27 01:17:00 $ + * @version $Revision: 1.5 $ $Date: 2002/02/28 07:04:36 $ */ public class WARDirContext extends BaseDirContext { @@ -788,6 +788,32 @@ ZipEntry entry = (ZipEntry) entryList.nextElement(); String name = normalize(entry); int pos = name.lastIndexOf('/'); + // Check that parent entries exist and, if not, create them. + // This fixes a bug for war files that don't record separate + // zip entries for the directories. + int currentPos = -1; + int lastPos = 0; + while ((currentPos = name.indexOf('/', lastPos)) != -1) { + Name parentName = new CompositeName(name.substring(0, lastPos)); + Name childName = new CompositeName(name.substring(0, currentPos)); + String entryName = name.substring(lastPos, currentPos); + // Parent should have been created in last cycle through + // this loop + Entry parent = treeLookup(parentName); + Entry child = treeLookup(childName); + if (child == null) { + // Create a new entry for missing entry and strip off + // the leading '/' character and appended on by the + // normalize method and add '/' character to end to + // signify that it is a directory entry + String zipName = name.substring(1, currentPos) + "/"; + child = new Entry(entryName, new ZipEntry(zipName)); + if (parent != null) + parent.addChild(child); + } + // Increment lastPos + lastPos = currentPos + 1; + } String entryName = name.substring(pos + 1, name.length()); Name compositeName = new CompositeName(name.substring(0, pos)); Entry parent = treeLookup(compositeName); -- To unsubscribe, e-mail: For additional commands, e-mail: