本文整理汇总了Java中org.apache.tools.zip.ZipEntry.getUnixMode方法的典型用法代码示例。如果您正苦于以下问题:Java ZipEntry.getUnixMode方法的具体用法?Java ZipEntry.getUnixMode怎么用?Java ZipEntry.getUnixMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.zip.ZipEntry
的用法示例。
在下文中一共展示了ZipEntry.getUnixMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnixMode
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
/**
* Determine a Resource's Unix mode or return the given default
* value if not available.
*/
private int getUnixMode(final Resource r, final ZipFile zf, final int defaultMode) {
int unixMode = defaultMode;
if (zf != null) {
final ZipEntry ze = zf.getEntry(r.getName());
unixMode = ze.getUnixMode();
if ((unixMode == 0 || unixMode == UnixStat.DIR_FLAG)
&& !preserve0Permissions) {
unixMode = defaultMode;
}
} else if (r instanceof ArchiveResource) {
unixMode = ((ArchiveResource) r).getMode();
}
return unixMode;
}
示例2: unzip
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
static private void unzip(File dir, File zipFile) throws IOException {
dir = dir.getAbsoluteFile(); // without absolutization, getParentFile below seems to fail
ZipFile zip = new ZipFile(zipFile);
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> entries = zip.getEntries();
try {
while (entries.hasMoreElements()) {
ZipEntry e = entries.nextElement();
File f = new File(dir, e.getName());
if (e.isDirectory()) {
f.mkdirs();
} else {
File p = f.getParentFile();
if (p != null) {
p.mkdirs();
}
InputStream input = zip.getInputStream(e);
try {
IOUtils.copy(input, f);
} finally {
input.close();
}
try {
FilePath target = new FilePath(f);
int mode = e.getUnixMode();
if (mode!=0) // Ant returns 0 if the archive doesn't record the access mode
target.chmod(mode);
} catch (InterruptedException ex) {
LOGGER.log(Level.WARNING, "unable to set permissions", ex);
}
f.setLastModified(e.getTime());
}
}
} finally {
zip.close();
}
}
示例3: setFilePermissions
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
private static void setFilePermissions(File file, ZipEntry entry) {
int permissions = entry.getUnixMode();
if (permissions != 0) {
UnixPermissions perm = new UnixPermissions(permissions);
if (perm.isOwnerExecute() || perm.isGroupExecute() || perm.isOwnerExecute()) {
file.setExecutable(true);
}
}
}
示例4: isSymlink
import org.apache.tools.zip.ZipEntry; //导入方法依赖的package包/类
private static boolean isSymlink(ZipEntry entry)
{
return (entry.getUnixMode() & ATTR_SYMLINK) == ATTR_SYMLINK;
}