bodewig     2003/07/30 05:23:10

  Modified:    src/main/org/apache/tools/ant/taskdefs Zip.java
  Log:
  Keep permissions of directories as well when updating a zip archive.
  
  PR: 21308
  
  Revision  Changes    Path
  1.112     +28 -1     ant/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.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- Zip.java  22 Jul 2003 11:37:21 -0000      1.111
  +++ Zip.java  30 Jul 2003 12:23:10 -0000      1.112
  @@ -449,12 +449,24 @@
                       DirectoryScanner ds =
                           oldFiles.getDirectoryScanner(getProject());
                       ((ZipScanner) ds).setEncoding(encoding);
  +
                       String[] f = ds.getIncludedFiles();
                       Resource[] r = new Resource[f.length];
                       for (int i = 0; i < f.length; i++) {
                           r[i] = ds.getResource(f[i]);
                       }
   
  +                    if (!doFilesonly) {
  +                        String[] d = ds.getIncludedDirectories();
  +                        Resource[] dr = new Resource[d.length];
  +                        for (int i = 0; i < d.length; i++) {
  +                            dr[i] = ds.getResource(d[i]);
  +                        }
  +                        Resource[] tmp = r;
  +                        r = new Resource[tmp.length + dr.length];
  +                        System.arraycopy(dr, 0, r, 0, dr.length);
  +                        System.arraycopy(tmp, 0, r, dr.length, tmp.length);
  +                    }                    
                       addResources(oldFiles, r, zOut);
                   }
                   finalizeZipOutputStream(zOut);
  @@ -596,7 +608,22 @@
                       name = name + "/";
                   }
   
  -                addParentDirs(base, name, zOut, prefix, dirMode);
  +                if (!doFilesonly && !dealingWithFiles 
  +                    && resources[i].isDirectory() 
  +                    && !zfs.hasDirModeBeenSet()) {
  +                    int nextToLastSlash = name.lastIndexOf("/",
  +                                                           name.length() - 
2);
  +                    if (nextToLastSlash != -1) {
  +                        addParentDirs(base, name.substring(0, 
  +                                                           nextToLastSlash + 
1),
  +                                      zOut, prefix, dirMode);
  +                    }
  +                    ZipEntry ze = zf.getEntry(resources[i].getName());
  +                    addParentDirs(base, name, zOut, prefix, 
ze.getUnixMode());
  +                    
  +                } else {
  +                    addParentDirs(base, name, zOut, prefix, dirMode);
  +                }
   
                   if (!resources[i].isDirectory() && dealingWithFiles) {
                       File f = fileUtils.resolveFile(base,
  
  
  

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

Reply via email to