本文整理汇总了Java中org.apache.tools.zip.ZipEntry.setUnixMode方法的典型用法代码示例。如果您正苦于以下问题:Java ZipEntry.setUnixMode方法的具体用法?Java ZipEntry.setUnixMode怎么用?Java ZipEntry.setUnixMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.zip.ZipEntry
的用法示例。
在下文中一共展示了ZipEntry.setUnixMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTo
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
public void writeTo(OutputStream out) throws IOException {
final Set<String> filenames = new HashSet<String>();
final ZipOutputStream zipout = new ZipOutputStream(out);
for (IFile f : container.getFiles()) {
assertNoAbsolutePath(f);
assertNoDuplicates(filenames, f);
ZipEntry entry = new ZipEntry(f.getLocalPath());
entry.setTime(f.getLastModified());
if (f.getPermissions() != IFile.UNDEF_PERMISSIONS) {
entry.setUnixMode(f.getPermissions());
}
zipout.putNextEntry(entry);
f.writeTo(zipout);
zipout.closeEntry();
}
zipout.finish();
}
示例2: visitFile
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
private void visitFile(FileCopyDetails fileDetails) {
try {
ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
archiveEntry.setTime(fileDetails.getLastModified());
archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
fileDetails.copyTo(zipOutStr);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
}
}
示例3: visitDir
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
private void visitDir(FileCopyDetails dirDetails) {
try {
// Trailing slash in name indicates that entry is a directory
ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
archiveEntry.setTime(dirDetails.getLastModified());
archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
zipOutStr.putNextEntry(archiveEntry);
zipOutStr.closeEntry();
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
}
}
示例4: zipDir
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
/**
* Add a directory to the zip stream.
* @param dir the directory to add to the archive
* @param zOut the stream to write to
* @param vPath the name this entry shall have in the archive
* @param mode the Unix permissions to set.
* @param extra ZipExtraFields to add
* @throws IOException on error
* @since Ant 1.8.0
*/
protected void zipDir(final Resource dir, final ZipOutputStream zOut, final String vPath,
final int mode, final ZipExtraField[] extra)
throws IOException {
if (doFilesonly) {
logWhenWriting("skipping directory " + vPath
+ " for file-only archive",
Project.MSG_VERBOSE);
return;
}
if (addedDirs.get(vPath) != null) {
// don't add directories we've already added.
// no warning if we try, it is harmless in and of itself
return;
}
logWhenWriting("adding directory " + vPath, Project.MSG_VERBOSE);
addedDirs.put(vPath, vPath);
if (!skipWriting) {
final ZipEntry ze = new ZipEntry(vPath);
// ZIPs store time with a granularity of 2 seconds, round up
final int millisToAdd = roundUp ? ROUNDUP_MILLIS : 0;
if (fixedModTime != null) {
ze.setTime(modTimeMillis);
} else if (dir != null && dir.isExists()) {
ze.setTime(dir.getLastModified() + millisToAdd);
} else {
ze.setTime(System.currentTimeMillis() + millisToAdd);
}
ze.setSize(0);
ze.setMethod(ZipEntry.STORED);
// This is faintly ridiculous:
ze.setCrc(EMPTY_CRC);
ze.setUnixMode(mode);
if (extra != null) {
ze.setExtraFields(extra);
}
zOut.putNextEntry(ze);
}
}