src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
changeset 58845 e492513d3630
parent 58822 9d95d8a8b750
child 59112 fe87a92570db
equal deleted inserted replaced
58844:5a0e0d0b3a27 58845:e492513d3630
   737                     else if (eSrc.file != null) {
   737                     else if (eSrc.file != null) {
   738                         u.file = getTempPathForEntry(null);
   738                         u.file = getTempPathForEntry(null);
   739                         Files.copy(eSrc.file, u.file, REPLACE_EXISTING);
   739                         Files.copy(eSrc.file, u.file, REPLACE_EXISTING);
   740                     }
   740                     }
   741                 }
   741                 }
   742             }
   742             } else if (eSrc.type == Entry.CEN && eSrc.method != defaultCompressionMethod) {
       
   743 
       
   744                 /**
       
   745                  * We are copying a file within the same Zip file using a
       
   746                  * different compression method.
       
   747                  */
       
   748                 try (InputStream in = newInputStream(src);
       
   749                      OutputStream out = newOutputStream(dst,
       
   750                              CREATE, TRUNCATE_EXISTING, WRITE)) {
       
   751                     in.transferTo(out);
       
   752                 }
       
   753                 u = getEntry(dst);
       
   754             }
       
   755 
   743             if (!hasCopyAttrs)
   756             if (!hasCopyAttrs)
   744                 u.mtime = u.atime= u.ctime = System.currentTimeMillis();
   757                 u.mtime = u.atime= u.ctime = System.currentTimeMillis();
   745             update(u);
   758             update(u);
   746             if (deletesrc)
   759             if (deletesrc)
   747                 updateDelete(eSrc);
   760                 updateDelete(eSrc);
   787                         is.transferTo(os);
   800                         is.transferTo(os);
   788                     }
   801                     }
   789                     return os;
   802                     return os;
   790                 }
   803                 }
   791                 return getOutputStream(supportPosix ?
   804                 return getOutputStream(supportPosix ?
   792                     new PosixEntry((PosixEntry)e, Entry.NEW) : new Entry(e, Entry.NEW));
   805                     new PosixEntry((PosixEntry)e, Entry.NEW, defaultCompressionMethod)
       
   806                         : new Entry(e, Entry.NEW, defaultCompressionMethod));
   793             } else {
   807             } else {
   794                 if (!hasCreate && !hasCreateNew)
   808                 if (!hasCreate && !hasCreateNew)
   795                     throw new NoSuchFileException(getString(path));
   809                     throw new NoSuchFileException(getString(path));
   796                 checkParents(path);
   810                 checkParents(path);
   797                 return getOutputStream(supportPosix ?
   811                 return getOutputStream(supportPosix ?
  2334         }
  2348         }
  2335 
  2349 
  2336         Entry(byte[] name, Path file, int type, FileAttribute<?>... attrs) {
  2350         Entry(byte[] name, Path file, int type, FileAttribute<?>... attrs) {
  2337             this(name, type, false, METHOD_STORED, attrs);
  2351             this(name, type, false, METHOD_STORED, attrs);
  2338             this.file = file;
  2352             this.file = file;
       
  2353         }
       
  2354 
       
  2355         Entry(Entry e, int type, int compressionMethod) {
       
  2356             this(e, type);
       
  2357             this.method = compressionMethod;
  2339         }
  2358         }
  2340 
  2359 
  2341         Entry(Entry e, int type) {
  2360         Entry(Entry e, int type) {
  2342             name(e.name);
  2361             name(e.name);
  2343             this.isdir     = e.isdir;
  2362             this.isdir     = e.isdir;
  2903 
  2922 
  2904         PosixEntry(byte[] name, Path file, int type, FileAttribute<?>... attrs) {
  2923         PosixEntry(byte[] name, Path file, int type, FileAttribute<?>... attrs) {
  2905             super(name, file, type, attrs);
  2924             super(name, file, type, attrs);
  2906         }
  2925         }
  2907 
  2926 
       
  2927         PosixEntry(PosixEntry e, int type, int compressionMethod) {
       
  2928             super(e, type);
       
  2929             this.method = compressionMethod;
       
  2930         }
       
  2931 
  2908         PosixEntry(PosixEntry e, int type) {
  2932         PosixEntry(PosixEntry e, int type) {
  2909             super(e, type);
  2933             super(e, type);
  2910             this.owner = e.owner;
  2934             this.owner = e.owner;
  2911             this.group = e.group;
  2935             this.group = e.group;
  2912         }
  2936         }