src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java
changeset 51795 feb4c9e03aed
parent 51787 ba51515b64e5
child 52008 6f04692c7d51
equal deleted inserted replaced
51794:4129f43607cb 51795:feb4c9e03aed
   608             e.size = e.bytes.length;
   608             e.size = e.bytes.length;
   609             e.crc = -1;
   609             e.crc = -1;
   610             super.close();
   610             super.close();
   611             update(e);
   611             update(e);
   612         }
   612         }
       
   613     }
       
   614 
       
   615     private int getCompressMethod(FileAttribute<?>... attrs) {
       
   616          return defaultMethod;
   613     }
   617     }
   614 
   618 
   615     // Returns a Writable/ReadByteChannel for now. Might consdier to use
   619     // Returns a Writable/ReadByteChannel for now. Might consdier to use
   616     // newFileChannel() instead, which dump the entry data into a regular
   620     // newFileChannel() instead, which dump the entry data into a regular
   617     // file on the default file system and create a FileChannel on top of
   621     // file on the default file system and create a FileChannel on top of
   651                 }
   655                 }
   652                 if (!options.contains(CREATE) && !options.contains(CREATE_NEW))
   656                 if (!options.contains(CREATE) && !options.contains(CREATE_NEW))
   653                     throw new NoSuchFileException(getString(path));
   657                     throw new NoSuchFileException(getString(path));
   654                 checkParents(path);
   658                 checkParents(path);
   655                 return new EntryOutputChannel(
   659                 return new EntryOutputChannel(
   656                     new Entry(path, Entry.NEW, false, defaultMethod));
   660                     new Entry(path, Entry.NEW, false, getCompressMethod(attrs)));
   657 
   661 
   658             } finally {
   662             } finally {
   659                 endRead();
   663                 endRead();
   660             }
   664             }
   661         } else {
   665         } else {
   719                                            .provider()
   723                                            .provider()
   720                                            .newFileChannel(tmpfile, options, attrs);
   724                                            .newFileChannel(tmpfile, options, attrs);
   721             final Entry u = isFCH ? e : new Entry(path, tmpfile, Entry.FILECH);
   725             final Entry u = isFCH ? e : new Entry(path, tmpfile, Entry.FILECH);
   722             if (forWrite) {
   726             if (forWrite) {
   723                 u.flag = FLAG_DATADESCR;
   727                 u.flag = FLAG_DATADESCR;
   724                 u.method = METHOD_DEFLATED;
   728                 u.method = getCompressMethod(attrs);
   725             }
   729             }
   726             // is there a better way to hook into the FileChannel's close method?
   730             // is there a better way to hook into the FileChannel's close method?
   727             return new FileChannel() {
   731             return new FileChannel() {
   728                 public int write(ByteBuffer src) throws IOException {
   732                 public int write(ByteBuffer src) throws IOException {
   729                     return fch.write(src);
   733                     return fch.write(src);
  1405         public void close() throws IOException {
  1409         public void close() throws IOException {
  1406             if (isClosed)
  1410             if (isClosed)
  1407                 return;
  1411                 return;
  1408             isClosed = true;
  1412             isClosed = true;
  1409             e.size = e.csize = written;
  1413             e.size = e.csize = written;
  1410             e.size = crc.getValue();
  1414             e.crc = crc.getValue();
  1411         }
  1415         }
  1412     }
  1416     }
  1413 
  1417 
  1414     // Wrapper output stream class to write out a "deflated" entry.
  1418     // Wrapper output stream class to write out a "deflated" entry.
  1415     // (1) this class does not close the underlying out stream when
  1419     // (1) this class does not close the underlying out stream when