当前位置: 首页>>代码示例>>Java>>正文


Java ZipArchiveEntry.isUnixSymlink方法代码示例

本文整理汇总了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry.isUnixSymlink方法的典型用法代码示例。如果您正苦于以下问题:Java ZipArchiveEntry.isUnixSymlink方法的具体用法?Java ZipArchiveEntry.isUnixSymlink怎么用?Java ZipArchiveEntry.isUnixSymlink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.compress.archivers.zip.ZipArchiveEntry的用法示例。


在下文中一共展示了ZipArchiveEntry.isUnixSymlink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extract

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private static void extract(ZipArchiveEntry zipArchiveEntry, ZipFile zipFile, File outputDir) throws IOException {
    File extractedFile = new File(outputDir, zipArchiveEntry.getName());
    FileUtils.forceMkdir(extractedFile.getParentFile());
    if (zipArchiveEntry.isUnixSymlink()) {
        if (PosixUtil.isPosixFileStore(outputDir)) {
            logger.debug("Extracting [l] "+zipArchiveEntry.getName());
            String symlinkTarget = zipFile.getUnixSymlink(zipArchiveEntry);
            Files.createSymbolicLink(extractedFile.toPath(), new File(symlinkTarget).toPath());
        } else {
            logger.debug("Skipping ! [l] "+zipArchiveEntry.getName());
        }
    } else if (zipArchiveEntry.isDirectory()) {
        logger.debug("Extracting [d] "+zipArchiveEntry.getName());
        FileUtils.forceMkdir(extractedFile);
    } else {
        logger.debug("Extracting [f] "+zipArchiveEntry.getName());
        try (
                InputStream in = zipFile.getInputStream(zipArchiveEntry);
                OutputStream out = new FileOutputStream(extractedFile)
        ) {
            IOUtils.copy(in, out);
        }
    }
    updatePermissions(extractedFile, zipArchiveEntry.getUnixMode());
}
 
开发者ID:ctco,项目名称:gradle-mobile-plugin,代码行数:26,代码来源:ZipUtil.java

示例2: getZipArchiveEntryNames

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
private static List<String> getZipArchiveEntryNames(File sourceZip) throws IOException {
    List<String> content = new ArrayList<>();
    try (ZipFile zipFile = new ZipFile(sourceZip);) {
        List<ZipArchiveEntry> zipEntries = Collections.list(zipFile.getEntries());
        for (ZipArchiveEntry zipEntry : zipEntries) {
            if (zipEntry.isUnixSymlink()) {
                content.add("[l]"+zipEntry.getName());
            } else if (zipEntry.isDirectory()) {
                content.add("[d]"+zipEntry.getName());
            } else {
                content.add("[f]"+zipEntry.getName());
            }
        }
    }
    Collections.sort(content);
    return content;
}
 
开发者ID:ctco,项目名称:gradle-mobile-plugin,代码行数:18,代码来源:ZipUtilTest.java

示例3: extractAll

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public static void extractAll(String zipFile, String extractDir) throws Exception {
	ZipFile unzipFile = new ZipFile(zipFile);
	try {
		File root = new File(extractDir);
		Enumeration<ZipArchiveEntry> fileHeaderList = unzipFile.getEntries();
		while(fileHeaderList.hasMoreElements()) {
			ZipArchiveEntry fileHeader = fileHeaderList.nextElement();
			if (fileHeader.isDirectory()) {
				//...
			} else if (!fileHeader.isUnixSymlink()) {
				File f = new File(root, fileHeader.getName());
				File dir = f.getParentFile();
				if (!dir.exists()) {
					dir.mkdirs();
				}
				FileOutputStream fout = new FileOutputStream(f);
				try {
					IOUtils.copy(unzipFile.getInputStream(fileHeader), fout);
				} finally {
					try {
						fout.close();
					} catch (Throwable e) {
					}
				}
				f.setLastModified(fileHeader.getLastModifiedDate().getTime());
			}
		}
	} finally {
		ZipFile.closeQuietly(unzipFile);
	}
}
 
开发者ID:BeckYang,项目名称:TeamFileList,代码行数:32,代码来源:ZipUtil.java

示例4: extract

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //导入方法依赖的package包/类
public void extract(IProgressMonitor monitor, IProject project) throws Exception {
	HashSet<IContainer> newdir = new HashSet<IContainer>();
	ArrayList<ZipArchiveEntry> fileHeaderList = new ArrayList<ZipArchiveEntry>();
	for (Enumeration<ZipArchiveEntry> ez = zipFile.getEntries(); ez.hasMoreElements();) {
		fileHeaderList.add(ez.nextElement());
	}
	monitor.beginTask("unzip file", fileHeaderList.size());
	Iterator<ZipArchiveEntry> iter = fileHeaderList.iterator();
	while(!monitor.isCanceled() && iter.hasNext()) {
		ZipArchiveEntry fileHeader = iter.next();
		if (fileHeader.isDirectory()) {
			//need to handle?
		} else if (!fileHeader.isUnixSymlink()){
			IFile file = project.getFile(fileHeader.getName());
			boolean refreshFile = file.exists();
			
			InputStream is = zipFile.getInputStream(fileHeader);
			try {
				if (refreshFile) {
					file.setContents(is, true, false, monitor);
					file.refreshLocal(IFile.DEPTH_ZERO, monitor);
					newdir.add(file.getParent());
				} else {
					if (!file.getParent().exists()) {
						IPath path = file.getProjectRelativePath().removeLastSegments(1);
						int len = path.segmentCount() - 1;
						for (int i = len; i >= 0; i--) {
							IFolder fd = project.getFolder(path.removeLastSegments(i));
							if (!fd.exists()) {
								fd.create(true, true, monitor);
							}
						}
					}
					file.create(is, true, monitor);
				}
			} finally {
				//is.close();//file.setContents(...) already do it
			}
		}
		monitor.worked(1);
	}
	//refresh dir...
	for (Iterator iterator = newdir.iterator(); iterator.hasNext();) {
		IContainer container = (IContainer) iterator.next();
		container.refreshLocal(IFile.DEPTH_ONE, monitor);
	}
}
 
开发者ID:BeckYang,项目名称:TeamFileList,代码行数:48,代码来源:ZipUtil.java


注:本文中的org.apache.commons.compress.archivers.zip.ZipArchiveEntry.isUnixSymlink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。