예제 #1
0
  private boolean readFileHeader(MyBufferedInputStream baseStream, String fileToFind)
      throws IOException {
    LocalFileHeader header = new LocalFileHeader();
    header.readFrom(baseStream);

    if (header.Signature != LocalFileHeader.FILE_HEADER_SIGNATURE) {
      return false;
    }
    if (header.FileName != null) {
      myFileHeaders.put(header.FileName, header);
      if (header.FileName.equalsIgnoreCase(fileToFind)) {
        return true;
      }
    }
    if ((header.Flags & 0x08) == 0) {
      baseStream.skip(header.CompressedSize);
    } else {
      findAndReadDescriptor(baseStream, header);
    }
    return false;
  }
예제 #2
0
 /** Finds descriptor of the last header and installs sizes of files */
 private void findAndReadDescriptor(MyBufferedInputStream baseStream, LocalFileHeader header)
     throws IOException {
   final Decompressor decompressor = Decompressor.init(baseStream, header);
   int uncompressedSize = 0;
   while (true) {
     int blockSize = decompressor.read(null, 0, 2048);
     if (blockSize <= 0) {
       break;
     }
     uncompressedSize += blockSize;
   }
   header.UncompressedSize = uncompressedSize;
   Decompressor.storeDecompressor(decompressor);
 }