org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory64()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory64()方法的一些代码示例,展示了ZipFile.positionAtCentralDirectory64()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipFile.positionAtCentralDirectory64()方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipFile
类名称:ZipFile
方法名:positionAtCentralDirectory64

ZipFile.positionAtCentralDirectory64介绍

[英]Parses the "Zip64 end of central directory locator", finds the "Zip64 end of central directory record" using the parsed information, parses that and positions the stream at the first central directory record. Expects stream to be positioned right behind the "Zip64 end of central directory locator"'s signature.
[中]解析“Zip64中央目录结束定位器”,使用解析的信息查找“Zip64中央目录结束记录”,解析该信息,并将流定位到第一个中央目录记录。希望流正好位于“Zip64中央目录定位器端”的签名后面。

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Searches for either the "Zip64 end of central directory
 * locator" or the "End of central dir record", parses
 * it and positions the stream at the first central directory
 * record.
 */
private void positionAtCentralDirectory()
  throws IOException {
  positionAtEndOfCentralDirectoryRecord();
  boolean found = false;
  final boolean searchedForZip64EOCD =
    archive.position() > ZIP64_EOCDL_LENGTH;
  if (searchedForZip64EOCD) {
    archive.position(archive.position() - ZIP64_EOCDL_LENGTH);
    wordBbuf.rewind();
    IOUtils.readFully(archive, wordBbuf);
    found = Arrays.equals(ZipArchiveOutputStream.ZIP64_EOCD_LOC_SIG,
               wordBuf);
  }
  if (!found) {
    // not a ZIP64 archive
    if (searchedForZip64EOCD) {
      skipBytes(ZIP64_EOCDL_LENGTH - WORD);
    }
    positionAtCentralDirectory32();
  } else {
    positionAtCentralDirectory64();
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Searches for either the "Zip64 end of central directory
 * locator" or the "End of central dir record", parses
 * it and positions the stream at the first central directory
 * record.
 */
private void positionAtCentralDirectory()
  throws IOException {
  positionAtEndOfCentralDirectoryRecord();
  boolean found = false;
  final boolean searchedForZip64EOCD =
    archive.position() > ZIP64_EOCDL_LENGTH;
  if (searchedForZip64EOCD) {
    archive.position(archive.position() - ZIP64_EOCDL_LENGTH);
    wordBbuf.rewind();
    IOUtils.readFully(archive, wordBbuf);
    found = Arrays.equals(ZipArchiveOutputStream.ZIP64_EOCD_LOC_SIG,
               wordBuf);
  }
  if (!found) {
    // not a ZIP64 archive
    if (searchedForZip64EOCD) {
      skipBytes(ZIP64_EOCDL_LENGTH - WORD);
    }
    positionAtCentralDirectory32();
  } else {
    positionAtCentralDirectory64();
  }
}

相关文章