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


Java ZipEntry.setUnixMode方法代码示例

本文整理汇总了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();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:Files.java

示例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);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:ZipCopyAction.java

示例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);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:ZipCopyAction.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:55,代码来源:Zip.java


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