Java Code Examples for net.lingala.zip4j.model.FileHeader#getOffsetLocalHeader()

The following examples show how to use net.lingala.zip4j.model.FileHeader#getOffsetLocalHeader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeaderVerifier.java    From zip4j with Apache License 2.0 6 votes vote down vote up
private static InputStream positionRandomAccessFileToLocalFileHeaderStart(File generatedZipFile, String fileNameInZip)
    throws IOException{

  ZipFile zipFile = new ZipFile(generatedZipFile);
  FileHeader fileHeader = zipFile.getFileHeader(fileNameInZip);

  if (fileHeader == null) {
    throw new RuntimeException("Cannot find an entry with name: " + fileNameInZip + " in zip file: "
        + generatedZipFile);
  }

  InputStream inputStream = new FileInputStream(generatedZipFile);
  if (inputStream.skip(fileHeader.getOffsetLocalHeader()) != fileHeader.getOffsetLocalHeader()) {
    throw new IOException("Cannot skip " + fileHeader.getOffsetLocalHeader() + " bytes for entry "
        + fileHeader.getFileName());
  }
  return inputStream;
}
 
Example 2
Source File: HeaderWriter.java    From zip4j with Apache License 2.0 4 votes vote down vote up
private boolean isZip64Entry(FileHeader fileHeader) {
  return fileHeader.getCompressedSize() >= ZIP_64_SIZE_LIMIT
      || fileHeader.getUncompressedSize() >= ZIP_64_SIZE_LIMIT
      || fileHeader.getOffsetLocalHeader() >= ZIP_64_SIZE_LIMIT
      || fileHeader.getDiskNumberStart() >= ZIP_64_NUMBER_OF_ENTRIES_LIMIT;
}