src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java

Print this page

        

@@ -610,10 +610,14 @@
             super.close();
             update(e);
         }
     }
 
+    private int getCompressMethod(FileAttribute<?>... attrs) {
+         return defaultMethod;
+    }
+
     // Returns a Writable/ReadByteChannel for now. Might consdier to use
     // newFileChannel() instead, which dump the entry data into a regular
     // file on the default file system and create a FileChannel on top of
     // it.
     SeekableByteChannel newByteChannel(byte[] path,

@@ -651,11 +655,11 @@
                 }
                 if (!options.contains(CREATE) && !options.contains(CREATE_NEW))
                     throw new NoSuchFileException(getString(path));
                 checkParents(path);
                 return new EntryOutputChannel(
-                    new Entry(path, Entry.NEW, false, defaultMethod));
+                    new Entry(path, Entry.NEW, false, getCompressMethod(attrs)));
 
             } finally {
                 endRead();
             }
         } else {

@@ -719,11 +723,11 @@
                                            .provider()
                                            .newFileChannel(tmpfile, options, attrs);
             final Entry u = isFCH ? e : new Entry(path, tmpfile, Entry.FILECH);
             if (forWrite) {
                 u.flag = FLAG_DATADESCR;
-                u.method = METHOD_DEFLATED;
+                u.method = getCompressMethod(attrs);
             }
             // is there a better way to hook into the FileChannel's close method?
             return new FileChannel() {
                 public int write(ByteBuffer src) throws IOException {
                     return fch.write(src);

@@ -1405,11 +1409,11 @@
         public void close() throws IOException {
             if (isClosed)
                 return;
             isClosed = true;
             e.size = e.csize = written;
-            e.size = crc.getValue();
+            e.crc = crc.getValue();
         }
     }
 
     // Wrapper output stream class to write out a "deflated" entry.
     // (1) this class does not close the underlying out stream when