本文整理了Java中com.android.tools.build.bundletool.model.ZipPath.subpath()
方法的一些代码示例,展示了ZipPath.subpath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipPath.subpath()
方法的具体详情如下:
包路径:com.android.tools.build.bundletool.model.ZipPath
类名称:ZipPath
方法名:subpath
暂无
代码示例来源:origin: google/bundletool
private static Optional<NativeLibraries> generateNativeLibrariesTargeting(BundleModule module) {
// Validation ensures that files under "lib/" conform to pattern "lib/<abi-dir>/file.so".
// We extract the distinct "lib/<abi-dir>" directories.
ImmutableList<String> libAbiDirs =
module
.findEntriesUnderPath(BundleModule.LIB_DIRECTORY)
.map(ModuleEntry::getPath)
.filter(path -> path.getNameCount() > 2)
.map(path -> path.subpath(0, 2))
.map(ZipPath::toString)
.distinct()
.collect(toImmutableList());
if (libAbiDirs.isEmpty()) {
return Optional.empty();
}
return Optional.of(new TargetingGenerator().generateTargetingForNativeLibraries(libAbiDirs));
}
代码示例来源:origin: google/bundletool
/**
* Indexes files under "lib/" based on the ABI directory (example keys are "lib/x86", "lib/mips").
*/
private static ImmutableMultimap<ZipPath, ModuleEntry> indexLibFilesByAbiDir(
BundleModule module) {
return module.getEntries().stream()
.filter(entry -> entry.getPath().startsWith(LIB_DIRECTORY))
.collect(
toImmutableSetMultimap(entry -> entry.getPath().subpath(0, 2), Function.identity()));
}
代码示例来源:origin: google/bundletool
@Override
public ZipPath getPath() {
ZipPath path = ZipPath.create(getZipEntry().getName());
return path.subpath(getPathNamesToSkip(), path.getNameCount());
}
代码示例来源:origin: google/bundletool
/**
* Returns the base name of the subpath composed from the first element up to and including the
* given element index.
*
* <p>See {@link ZipPath#subpath} and {@link TargetedDirectory#getPathBaseName}.
*/
public String getSubPathBaseName(int maxIndex) {
return originalPath()
.subpath(0, maxIndex + 1)
.resolveSibling(getPathSegments().get(maxIndex).getName())
.toString();
}
代码示例来源:origin: google/bundletool
private static BundleMetadata readBundleMetadata(ZipFile bundleFile) {
BundleMetadata.Builder metadata = BundleMetadata.builder();
ZipUtils.allFileEntries(bundleFile)
.filter(entry -> ZipPath.create(entry.getName()).startsWith(METADATA_DIRECTORY))
.forEach(
zipEntry -> {
ZipPath bundlePath = ZipPath.create(zipEntry.getName());
// Strip the top-level metadata directory.
ZipPath metadataPath = bundlePath.subpath(1, bundlePath.getNameCount());
metadata.addFile(metadataPath, BufferedIo.inputStreamSupplier(bundleFile, zipEntry));
});
return metadata.build();
}
代码示例来源:origin: google/bundletool
@Test
public void testSubpath_incorrectInputs_throws() {
ZipPath path = ZipPath.create("foo/bar");
assertThrows(IllegalArgumentException.class, () -> path.subpath(0, 3));
assertThrows(IllegalArgumentException.class, () -> path.subpath(-1, 2));
assertThrows(IllegalArgumentException.class, () -> path.subpath(2, 1));
}
代码示例来源:origin: google/bundletool
@Test
public void testSubpathFromRoot_Throws() {
ZipPath root = ZipPath.create("");
assertThrows(IllegalArgumentException.class, () -> root.subpath(0, 0));
assertThrows(IllegalArgumentException.class, () -> root.subpath(0, 1));
}
代码示例来源:origin: google/bundletool
@Test
public void testSubpath() {
ZipPath path = ZipPath.create("foo/bar");
assertThat((Object) path.subpath(0, 1)).isEqualTo(ZipPath.create("foo"));
assertThat((Object) path.subpath(1, 2)).isEqualTo(ZipPath.create("bar"));
assertThat((Object) path.subpath(0, 2)).isEqualTo(ZipPath.create("foo/bar"));
}
代码示例来源:origin: google/bundletool
/**
* For a given collection of paths returns the order of traversal of their hierarchy tree.
*
* <p>The returned order assumes the path walk starts at the root and will also return non-leaf
* path nodes of the given paths. The order of traversal is lexicographical and is stable.
*/
public static List<ZipPath> toPathWalkingOrder(Collection<ZipPath> paths) {
ImmutableSortedSet.Builder<ZipPath> walkOrderedSet = ImmutableSortedSet.naturalOrder();
for (ZipPath path : paths) {
for (int i = 0; i < path.getNameCount(); i++) {
walkOrderedSet.add(path.subpath(0, i + 1));
}
}
return walkOrderedSet.build().asList();
}
代码示例来源:origin: google/bundletool
"Only files inside the root directory are supported but found: %s",
pathInModule);
return pathInModule.subpath(1, pathInModule.getNameCount());
代码示例来源:origin: google/bundletool
.map(libFile -> libFile.getPath().subpath(0, 2).toString())
.collect(toImmutableSet()),
nativeLibraries.getDirectoryList().stream()
代码示例来源:origin: google/bundletool
throw InvalidNativeArchitectureNameException.createForDirectory(file.subpath(0, 2));
内容来源于网络,如有侵权,请联系作者删除!