src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java

Print this page
rev 3516 : 7021582: convert jar/zip code and tests to use try-with-resources
Reviewed-by: XXX


 224             if (_verbose > 0)
 225                 Utils.log.info("bytes consumed = "+consumed);
 226             if (presetInput == null &&
 227                 !Utils.isPackMagic(Utils.readMagic(in0))) {
 228                 break;
 229             }
 230             if (_verbose > 0 ) {
 231                 if (presetInput != null)
 232                     Utils.log.info("unused input = "+presetInput);
 233             }
 234         }
 235     }
 236 
 237     void run(InputStream in, JarOutputStream jstream) throws IOException {
 238         run(in, jstream, null);
 239     }
 240 
 241     void run(File inFile, JarOutputStream jstream) throws IOException {
 242         // %%% maybe memory-map the file, and pass it straight into unpacker
 243         ByteBuffer mappedFile = null;
 244         FileInputStream fis = new FileInputStream(inFile);
 245         run(fis, jstream, mappedFile);
 246         fis.close();
 247         // Note:  caller is responsible to finish with jstream.
 248     }
 249 
 250     private void writeEntry(JarOutputStream j, String name,
 251                             long mtime, long lsize, boolean deflateHint,
 252                             ByteBuffer data0, ByteBuffer data1) throws IOException {
 253         int size = (int)lsize;
 254         if (size != lsize)
 255             throw new IOException("file too large: "+lsize);
 256 
 257         CRC32 crc32 = _crc32;
 258 
 259         if (_verbose > 1)
 260             Utils.log.fine("Writing entry: "+name+" size="+size
 261                              +(deflateHint?" deflated":""));
 262 
 263         if (_buf.length < size) {
 264             int newSize = size;
 265             while (newSize < _buf.length) {
 266                 newSize <<= 1;




 224             if (_verbose > 0)
 225                 Utils.log.info("bytes consumed = "+consumed);
 226             if (presetInput == null &&
 227                 !Utils.isPackMagic(Utils.readMagic(in0))) {
 228                 break;
 229             }
 230             if (_verbose > 0 ) {
 231                 if (presetInput != null)
 232                     Utils.log.info("unused input = "+presetInput);
 233             }
 234         }
 235     }
 236 
 237     void run(InputStream in, JarOutputStream jstream) throws IOException {
 238         run(in, jstream, null);
 239     }
 240 
 241     void run(File inFile, JarOutputStream jstream) throws IOException {
 242         // %%% maybe memory-map the file, and pass it straight into unpacker
 243         ByteBuffer mappedFile = null;
 244         try (FileInputStream fis = new FileInputStream(inFile)) {
 245             run(fis, jstream, mappedFile);
 246         }
 247         // Note:  caller is responsible to finish with jstream.
 248     }
 249 
 250     private void writeEntry(JarOutputStream j, String name,
 251                             long mtime, long lsize, boolean deflateHint,
 252                             ByteBuffer data0, ByteBuffer data1) throws IOException {
 253         int size = (int)lsize;
 254         if (size != lsize)
 255             throw new IOException("file too large: "+lsize);
 256 
 257         CRC32 crc32 = _crc32;
 258 
 259         if (_verbose > 1)
 260             Utils.log.fine("Writing entry: "+name+" size="+size
 261                              +(deflateHint?" deflated":""));
 262 
 263         if (_buf.length < size) {
 264             int newSize = size;
 265             while (newSize < _buf.length) {
 266                 newSize <<= 1;