ProjectPackageList.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:idecore 作者:
public void parseZip(byte[] zipFile, IProgressMonitor monitor) throws IOException {
    if (zipFile == null) {
        throw new IllegalArgumentException("File zip cannot be null");
    }

    if (logger.isDebugEnabled()) {
        ZipUtils.writeRetrieveZipToTempDir(zipFile);
    }

    monitor.subTask("Parsing retrieved zip response...");

    List<String> folderNames = projectService.getComponentFactory().getFolderNamesForFolderComponents();

    try (final QuietCloseable<ZipInputStream> c = QuietCloseable.make(new ZipInputStream(new ByteArrayInputStream(zipFile)))) {
        final ZipInputStream zis = c.get();

        for (;;) {
            ZipEntry ze = zis.getNextEntry();
            if (ze == null) {
                break;
            }

            byte[] fileContent = StreamUtils.getBytes(zis);
            String name = ze.getName();
            if (ze.isDirectory()) {
                continue;
            }

            ProjectPackage projectPackage = null;
            // path starts with package name
            if (startsWithPackageName(folderNames, name)) {
                projectPackage = getProjectPackage(name.split("/")[0]);
            } else if (size() > 0) {
                projectPackage = get(0);
            } else {
                projectPackage = getProjectPackage(Constants.DEFAULT_PACKAGED_NAME);
            }

            if (projectPackage == null) {
                continue;
            }

            projectPackage.addFilePathZipMapping(name, fileContent);
        }
    }

    monitorWork(monitor);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号