cvs commit: ant/src/main/org/apache/tools/zip ZipEntry.java ZipFile.java ZipLong.java ZipOutputStream.java ZipShort.java

2003-07-15 Thread conor
conor   2003/07/15 07:54:15

  Modified:src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
Zip.java
   src/main/org/apache/tools/ant/types Path.java
XMLCatalog.java ZipFileSet.java ZipScanner.java
   src/main/org/apache/tools/zip ZipEntry.java ZipFile.java
ZipLong.java ZipOutputStream.java ZipShort.java
  Log:
  style
  
  Revision  ChangesPath
  1.33  +3 -3  
ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -w -u -r1.32 -r1.33
  --- ExecuteJava.java  14 Jul 2003 13:42:32 -  1.32
  +++ ExecuteJava.java  15 Jul 2003 14:54:14 -  1.33
  @@ -112,7 +112,7 @@
   }
   
   /**
  - * @since 1.19, Ant 1.5
  + * @since Ant 1.5
*/
   public void setTimeout(Long timeout) {
   this.timeout = timeout;
  @@ -201,7 +201,7 @@
   }
   
   /**
  - * @since 1.19, Ant 1.5
  + * @since Ant 1.5
*/
   public void run() {
   final Object[] argument = { javaCommand.getArguments() };
  @@ -222,7 +222,7 @@
   }
   
   /**
  - * @since 1.19, Ant 1.5
  + * @since Ant 1.5
*/
   public synchronized void timeoutOccured(Watchdog w) {
   if (thread != null) {
  
  
  
  1.110 +15 -15ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -w -u -r1.109 -r1.110
  --- Zip.java  6 Jul 2003 09:57:37 -   1.109
  +++ Zip.java  15 Jul 2003 14:54:14 -  1.110
  @@ -317,8 +317,7 @@
   executeMain();
   skipWriting = false;
   executeMain();
  -}
  -else {
  +} else {
   executeMain();
   }
   }
  @@ -464,8 +463,8 @@
   // temporary file
   if (doUpdate) {
   if (!renamedFile.delete()) {
  -log (Warning: unable to delete temporary file  +
  - renamedFile.getName(), Project.MSG_WARN);
  +log (Warning: unable to delete temporary file 
  ++ renamedFile.getName(), Project.MSG_WARN);
   }
   }
   success = true;
  @@ -504,8 +503,8 @@
   try {
   fileUtils.rename(renamedFile, zipFile);
   } catch (IOException e) {
  -msg +=  (and I couldn't rename the temporary file  +
  -renamedFile.getName() +  back);
  +msg +=  (and I couldn't rename the temporary file 
  ++ renamedFile.getName() +  back);
   }
   }
   
  @@ -665,6 +664,7 @@
   try {
   os.close();
   } catch (IOException e) {
  +//ignore
   }
   }
   }
  @@ -744,8 +744,8 @@
   }
   } else if (emptyBehavior.equals(fail)) {
   throw new BuildException(Cannot create  + archiveType
  - +  archive  + zipFile +
  - : no files were included.,
  + +  archive  + zipFile
  + + : no files were included.,
getLocation());
   } else {
   // Create.
  @@ -1123,7 +1123,7 @@
*
* @since Ant 1.5.2
*/
  -protected final static boolean isEmpty(Resource[][] r) {
  +protected static final boolean isEmpty(Resource[][] r) {
   for (int i = 0; i  r.length; i++) {
   if (r[i].length  0) {
   return false;
  
  
  
  1.51  +31 -31ant/src/main/org/apache/tools/ant/types/Path.java
  
  Index: Path.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Path.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -w -u -r1.50 -r1.51
  
  
  
  1.27  +93 -100   ant/src/main/org/apache/tools/ant/types/XMLCatalog.java
  
  Index: XMLCatalog.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -w -u -r1.26 -r1.27
  --- 

cvs commit: ant/src/main/org/apache/tools/zip ZipEntry.java ZipFile.java

2003-07-03 Thread bodewig
bodewig 2003/07/03 08:38:40

  Modified:src/main/org/apache/tools/zip ZipEntry.java ZipFile.java
  Log:
  Improve algorithm that searches for the central directory - don't get fooled 
by signatures appearing inside payload.
  
  Revision  ChangesPath
  1.11  +2 -2  ant/src/main/org/apache/tools/zip/ZipEntry.java
  
  Index: ZipEntry.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipEntry.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ZipEntry.java 3 Jul 2003 15:00:36 -   1.10
  +++ ZipEntry.java 3 Jul 2003 15:38:39 -   1.11
  @@ -417,7 +417,7 @@
* @since 1.10
*/
   public boolean isDirectory() {
  - return getName().endsWith(/);
  +return getName().endsWith(/);
   }
   
   protected void setName(String name) {
  
  
  
  1.4   +39 -11ant/src/main/org/apache/tools/zip/ZipFile.java
  
  Index: ZipFile.java
  ===
  RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipFile.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ZipFile.java  3 Jul 2003 14:59:59 -   1.3
  +++ ZipFile.java  3 Jul 2003 15:38:39 -   1.4
  @@ -320,15 +320,42 @@
   }
   }
   
  +private static final int MIN_EOCD_SIZE =
  +/* end of central dir signature*/ 4 +
  +/* number of this disk */ 2 +
  +/* number of the disk with the */   +
  +/* start of the central directory  */ 2 +
  +/* total number of entries in  */   +
  +/* the central dir on this disk*/ 2 +
  +/* total number of entries in  */   +
  +/* the central dir */ 2 +
  +/* size of the central directory   */ 4 +
  +/* offset of start of central  */   +
  +/* directory with respect to   */   +
  +/* the starting disk number*/ 4 +
  +/* zipfile comment length  */ 2;
  +
  +private static final int CFD_LOCATOR_OFFSET =
  +/* end of central dir signature*/ 4 +
  +/* number of this disk */ 2 +
  +/* number of the disk with the */   +
  +/* start of the central directory  */ 2 +
  +/* total number of entries in  */   +
  +/* the central dir on this disk*/ 2 +
  +/* total number of entries in  */   +
  +/* the central dir */ 2 +
  +/* size of the central directory   */ 4;
  +
   /**
  - * Searches for the first occurence of the central file header
  - * signature.
  + * Searches for the quot;End of central dir recordquot;, parses
  + * it and positions the stream at the first central directory
  + * record.
*/
   private void positionAtCentralDirectory() 
   throws IOException, ZipException {
  -archive.seek(0);
  -int off = 0;
  -byte[] sig = ZipOutputStream.CFH_SIG.getBytes();
  +long off = archive.length() - MIN_EOCD_SIZE;
  +archive.seek(off);
  +byte[] sig = ZipOutputStream.EOCD_SIG.getBytes();
   int curr = archive.read();
   boolean found = false;
   while (curr != -1) {
  @@ -344,16 +371,17 @@
   }
   }
   }
  -archive.seek(++off);
  -} else {
  -off++;
   }
  +archive.seek(--off);
   curr = archive.read();
   }
   if (!found) {
   throw new ZipException(archive is not a ZIP archive);
   }
  -archive.seek(off);
  +archive.seek(off + CFD_LOCATOR_OFFSET);
  +byte[] cfdOffset = new byte[4];
  +archive.readFully(cfdOffset);
  +archive.seek((new ZipLong(cfdOffset)).getValue());
   }
   
   /**
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]