本文整理了Java中java.util.zip.ZipEntry.getCompressedSize()
方法的一些代码示例,展示了ZipEntry.getCompressedSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEntry.getCompressedSize()
方法的具体详情如下:
包路径:java.util.zip.ZipEntry
类名称:ZipEntry
方法名:getCompressedSize
[英]Gets the compressed size of this ZipEntry.
[中]获取此ZipEntry的压缩大小。
代码示例来源:origin: skylot/jadx
public static boolean isZipBomb(ZipEntry entry) {
long compressedSize = entry.getCompressedSize();
long uncompressedSize = entry.getSize();
if (compressedSize < 0 || uncompressedSize < 0) {
LOG.error("Zip bomb attack detected, invalid sizes: compressed {}, uncompressed {}, name {}",
compressedSize, uncompressedSize, entry.getName());
return true;
}
if (compressedSize * MAX_SIZE_DIFF < uncompressedSize) {
LOG.error("Zip bomb attack detected, invalid sizes: compressed {}, uncompressed {}, name {}",
compressedSize, uncompressedSize, entry.getName());
return true;
}
return false;
}
代码示例来源:origin: iBotPeaches/Apktool
@Override
public long getCompressedSize(String fileName)
throws DirectoryException {
ZipEntry entry = getZipFileEntry(fileName);
return entry.getCompressedSize();
}
代码示例来源:origin: robolectric/robolectric
long guessOffsetFor(ZipFile zipFile, ZipEntry zipEntry) {
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
long offset = 0;
while (zipEntries.hasMoreElements())
{
ZipEntry entry = zipEntries.nextElement();
long fileSize = 0;
long extra = entry.getExtra() == null ? 0 : entry.getExtra().length;
offset += 30 + entry.getName().length() + extra;
if (entry.getName().equals(zipEntry.getName())) {
return offset;
}
if(!entry.isDirectory())
{
fileSize = entry.getCompressedSize();
// Do stuff here with fileSize & offset
}
offset += fileSize;
}
throw new IllegalStateException("'" + zipEntry.getName() + "' not found");
}
/*
代码示例来源:origin: graphhopper/graphhopper
} else {
double factor = 1;
if (ze.getCompressedSize() > 0 && ze.getSize() > 0)
factor = (double) ze.getCompressedSize() / ze.getSize();
代码示例来源:origin: robolectric/robolectric
FileMap createEntryFileMap(ZipEntryRO entry)
{
// final _ZipEntryRO *zipEntry = reinterpret_cast<_ZipEntryRO*>(entry);
// const ZipEntry& ze = zipEntry->entry;
ZipEntry ze = entry.entry;
// int fd = GetFileDescriptor(mHandle);
int fd = -1;
int actualLen = 0;
if (ze.getMethod() == kCompressStored) {
actualLen = toIntExact(ze.getSize());
} else {
actualLen = toIntExact(ze.getCompressedSize());
}
FileMap newMap = new FileMap();
if (!newMap.createFromZip(mFileName, mHandle.zipFile, entry.entry, actualLen, true)) {
// delete newMap;
return null;
}
return newMap;
}
代码示例来源:origin: robolectric/robolectric
boolean getEntryInfo(org.robolectric.res.android.ZipFileRO.ZipEntryRO entry, Ref<Short> pMethod,
final Ref<Long> pUncompLen, Ref<Long> pCompLen, Ref<Long> pOffset,
final Ref<Long> pModWhen, Ref<Long> pCrc32)
{
final ZipEntryRO zipEntry = /*reinterpret_cast<ZipEntryRO*>*/(entry);
final ZipEntry ze = zipEntry.entry;
if (pMethod != null) {
pMethod.set((short) ze.getMethod());
}
if (pUncompLen != null) {
pUncompLen.set(ze.getSize()); // uncompressed_length
}
if (pCompLen != null) {
pCompLen.set(ze.getCompressedSize());
}
if (pOffset != null) {
throw new UnsupportedOperationException("Figure out offset");
// pOffset = ze.offset;
}
if (pModWhen != null) {
// todo pModWhen.set(ze.getLastModifiedTime().toMillis());
}
if (pCrc32 != null) {
pCrc32.set(ze.getCrc());
}
return true;
}
代码示例来源:origin: jphp-group/jphp
private static ArrayMemory zipEntryToArray(ZipEntry zipEntry) {
final ArrayMemory result = new ArrayMemory();
result.refOfIndex("name").assign(zipEntry.getName());
result.refOfIndex("crc").assign(zipEntry.getCrc());
result.refOfIndex("size").assign(zipEntry.getSize());
result.refOfIndex("compressedSize").assign(zipEntry.getCompressedSize());
result.refOfIndex("time").assign(zipEntry.getTime());
result.refOfIndex("method").assign(zipEntry.getMethod());
result.refOfIndex("comment").assign(zipEntry.getComment());
result.refOfIndex("directory").assign(zipEntry.isDirectory());
return result;
}
代码示例来源:origin: robovm/robovm
if (ze.getCompressedSize() == -1) {
ze.setCompressedSize(ze.getSize());
} else if (ze.getSize() == -1) {
ze.setSize(ze.getCompressedSize());
代码示例来源:origin: bonigarcia/webdrivermanager
long compressedSize = zipEntry.getCompressedSize();
log.trace("Unzipping {} (size: {} KB, compressed size: {} KB)",
name, size, compressedSize);
代码示例来源:origin: org.vx68k.quercus/quercus
/**
* Returns the size of the compressed data.
*
* @return -1, or compressed size
*/
public long zip_entry_compressedsize()
{
if (_entry == null)
return -1;
return _entry.getCompressedSize();
}
代码示例来源:origin: PrivacyApps/document-viewer
public long getCompressedSize() {
return entry.getCompressedSize();
}
代码示例来源:origin: stackoverflow.com
ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
ZipInputStream zis = new ZipInputStream(bis);
ZipEntry entry = zis.getNextEntry();
InputSource inputSource = new InputSource(new BoundedInputStream(zis, entry.getCompressedSize()));
代码示例来源:origin: stackoverflow.com
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
long offset = 0;
while (zipEntries.hasMoreElements())
{
ZipEntry entry = (ZipEntry)zipEntries.nextElement();
long fileSize = 0;
long extra = entry.getExtra() == null ? 0 : entry.getExtra().length;
offset += 30 + entry.getName().length() + extra;
if(!entry.isDirectory())
{
fileSize = entry.getCompressedSize();
// Do stuff here with fileSize & offset
}
offset += fileSize;
}
代码示例来源:origin: com.github.bloodshura/shurax
@Nullable
public Bytes getCompressedSize() {
long size = getHandle().getCompressedSize();
return size != -1 ? new Bytes(size) : null;
}
代码示例来源:origin: com.github.bloodshura/ignitium-core
@Nullable
public Bytes getCompressedSize() {
long size = getHandle().getCompressedSize();
return size != -1 ? new Bytes(size) : null;
}
代码示例来源:origin: GeeQuery/ef-orm
public XEntry(ZipEntry entry, long offset) {
this.entry = entry;
this.offset = offset;
// store size, compressed size, and crc-32 in data descriptor
// immediately following the compressed entry data
// store size, compressed size, and crc-32 in LOC header
this.flag = (entry.getMethod() == DEFLATED && (entry.getSize() == -1 || entry.getCompressedSize() == -1 || entry.getCrc() == -1))? 8: 0;
}
}
代码示例来源:origin: davidmoten/rxjava2-extras
public ZippedEntry(ZipEntry e, InputStream is) {
this.name = e.getName();
this.time = e.getTime();
// this.mtime = e.getLastModifiedTime();
// this.atime = e.getLastAccessTime();
// this.ctime = e.getCreationTime();
this.crc = e.getCrc();
this.size = e.getSize();
this.csize = e.getCompressedSize();
this.method = e.getMethod();
this.extra = e.getExtra();
this.comment = e.getComment();
this.is = is;
}
代码示例来源:origin: davidmoten/rxjava-extras
public ZippedEntry(ZipEntry e, InputStream is) {
this.name = e.getName();
this.time = e.getTime();
// this.mtime = e.getLastModifiedTime();
// this.atime = e.getLastAccessTime();
// this.ctime = e.getCreationTime();
this.crc = e.getCrc();
this.size = e.getSize();
this.csize = e.getCompressedSize();
this.method = e.getMethod();
this.extra = e.getExtra();
this.comment = e.getComment();
this.is = is;
}
代码示例来源:origin: GeeQuery/ef-orm
private void writeEXT(ZipEntry e) throws IOException {
writeInt(EXTSIG); // EXT header signature
writeInt(e.getCrc()); // crc-32
writeInt(e.getCompressedSize()); // compressed size
writeInt(e.getSize()); // uncompressed size
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public ZipEntryMatrix(ZipFile zipFile, ZipEntry zipEntry) {
this.zipFile = zipFile;
this.zipEntry = zipEntry;
setLabel(zipEntry.getName());
setMetaData("CompressedSize", zipEntry.getCompressedSize());
setMetaData("CRC", zipEntry.getCrc());
setMetaData("Method", zipEntry.getMethod());
setMetaData("Size", zipEntry.getSize());
setMetaData("Time", zipEntry.getTime());
setMetaData("IsDirectory", zipEntry.isDirectory());
setMetaData("Comment", zipEntry.getComment());
}
内容来源于网络,如有侵权,请联系作者删除!