gpt4 book ai didi

com.android.tools.build.apkzlib.zip.ZFile类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:30:43 32 4
gpt4 key购买 nike

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

ZFile介绍

暂无

代码示例

代码示例来源:origin: google/bundletool

minSdkVersion);
  ZFile zAapt2Files =
    new ZFile(binaryApk.toFile(), createZFileOptions(tempDir), /* readOnly= */ true)) {
 zOutputApk.mergeFrom(zAapt2Files, /* ignoreFilter= */ Predicates.alwaysFalse());
 zOutputApk.sortZipContents();
} catch (IOException e) {
 throw new UncheckedIOException(

代码示例来源:origin: google/bundletool

/** Takes the given APK and adds the files that weren't processed by AAPT2. */
private void addNonAapt2Files(ZFile zFile, ModuleSplit split) throws IOException {
 boolean extractNativeLibs = split.getAndroidManifest().getExtractNativeLibsValue().orElse(true);
 // Add the non-Aapt2 files.
 for (ModuleEntry entry : split.getEntries()) {
  ZipPath pathInApk = toApkEntryPath(entry.getPath());
  if (!FILES_FOR_AAPT2.apply(pathInApk)) {
   try (InputStream entryInputStream = entry.getContent()) {
    zFile.add(
      pathInApk.toString(),
      entryInputStream,
      shouldCompress(pathInApk, !extractNativeLibs, entry.shouldCompress()));
   }
  }
 }
}

代码示例来源:origin: google/bundletool

/**
 * Checks whether a zip file has been correctly zipaligned.
 *
 * @return {@code true} if the file has been correctly zipaligned.
 */
public static boolean checkAlignment(File zip) throws IOException {
 try (ZFile zfile = new ZFile(zip)) {
  for (StoredEntry entry : zfile.entries()) {
   CentralDirectoryHeader header = entry.getCentralDirectoryHeader();
   // Alignment only applies to uncompressed files.
   if (header.getCompressionInfoWithWait().getMethod().equals(CompressionMethod.STORE)) {
    int expectedAligment =
      NATIVE_LIB_PATTERN.matcher(header.getName()).matches()
        ? PAGE_ALIGNMENT
        : FOUR_BYTE_ALIGNMENT;
    long dataOffset = header.getOffset() + entry.getLocalHeaderSize();
    if (dataOffset % expectedAligment != 0) {
     System.out.println(
       String.format(
         "File '%s' is not aligned. dataOffset=%d, expectedAlignment=%d",
         header.getName(), dataOffset, expectedAligment));
     return false;
    }
   }
  }
 }
 return true;
}

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com