當前位置: 首頁>>代碼示例>>Java>>正文


Java ZipArchiveEntry.setCrc方法代碼示例

本文整理匯總了Java中org.apache.commons.compress.archivers.zip.ZipArchiveEntry.setCrc方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipArchiveEntry.setCrc方法的具體用法?Java ZipArchiveEntry.setCrc怎麽用?Java ZipArchiveEntry.setCrc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.compress.archivers.zip.ZipArchiveEntry的用法示例。


在下文中一共展示了ZipArchiveEntry.setCrc方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: entryToNewName

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
/**
 * Entry to new name.
 *
 * @param source the source
 * @param name the name
 * @return the zip archive entry
 * @throws ZipException the zip exception
 */
public static ZipArchiveEntry entryToNewName(ZipArchiveEntry source, String name) throws ZipException {
  if (source.getName().equals(name))
    return new ZipArchiveEntry(source);
  ZipArchiveEntry ret = new ZipArchiveEntry(name);
  byte[] extra = source.getExtra();
  if (extra != null) {
    ret.setExtraFields(ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ));
  } else {
    ret.setExtra(ExtraFieldUtils.mergeLocalFileDataData(source.getExtraFields(true)));
  }
  ret.setInternalAttributes(source.getInternalAttributes());
  ret.setExternalAttributes(source.getExternalAttributes());
  ret.setExtraFields(source.getExtraFields(true));
  ret.setCrc(source.getCrc());
  ret.setMethod(source.getMethod());
  ret.setSize(source.getSize());
  return ret;
}
 
開發者ID:NitorCreations,項目名稱:javaxdelta,代碼行數:27,代碼來源:JarDelta.java

示例2: visitEntry

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
@Override
public void visitEntry(ApkArchiveEntry entry) throws IOException {
	super.visitEntry(entry);

	if (includedFiles.contains(entry.getFilename())) {
		return;
	}

	ZipArchiveEntry zipEntry = new ZipArchiveEntry(entry.getFilename());
	includedFiles.add(entry.getFilename());

	if (entry.getMethod() == ZipEntry.STORED) {
		zipEntry.setSize(entry.getSize());
		zipEntry.setCrc(entry.getCrc());
	}

	zaos.setMethod(entry.getMethod());

	zaos.putArchiveEntry(zipEntry);
	IOUtils.copy(entry.getInputStream(), zaos);

	zaos.closeArchiveEntry();
}
 
開發者ID:testfairy,項目名稱:testfairy-jenkins-plugin,代碼行數:24,代碼來源:ApkArchiveWriter.java

示例3: newTailArchive

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
private static ArchiveEntry newTailArchive(String name, byte[] tail) {
    ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
    zipEntry.setSize(tail.length);
    zipEntry.setCompressedSize(zipEntry.getSize());
    CRC32 crc32 = new CRC32();
    crc32.update(tail);
    zipEntry.setCrc(crc32.getValue());
    return zipEntry;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:10,代碼來源:LogArchiver.java

示例4: newArchive

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
private static ArchiveEntry newArchive(File file) throws IOException {
    ZipArchiveEntry zipEntry = new ZipArchiveEntry(file.getName());
    zipEntry.setSize(file.length());
    zipEntry.setCompressedSize(zipEntry.getSize());
    zipEntry.setCrc(FileUtils.checksumCRC32(file));
    return zipEntry;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:8,代碼來源:LogArchiver.java

示例5: newStoredEntry

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
protected ArchiveEntry newStoredEntry(String name, byte[] data) {
    ZipArchiveEntry zipEntry = new ZipArchiveEntry(name);
    zipEntry.setSize(data.length);
    zipEntry.setCompressedSize(zipEntry.getSize());
    CRC32 crc32 = new CRC32();
    crc32.update(data);
    zipEntry.setCrc(crc32.getValue());
    return zipEntry;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:10,代碼來源:FoldersServiceBean.java

示例6: createArchiveEntry

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
@Override
public ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetBytes) {
    ZipArchiveEntry zipEntry = new ZipArchiveEntry(targetPath);
    zipEntry.setSize(targetSize);
    zipEntry.setMethod(ZipEntry.STORED);
    if (targetBytes != null) {
        zipEntry.setCrc(crc32Checksum(targetBytes));
    }
    return zipEntry;
}
 
開發者ID:trustsystems,項目名稱:elfinder-java-connector,代碼行數:11,代碼來源:ZipArchiver.java

示例7: isVulnerable

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; //導入方法依賴的package包/類
public boolean isVulnerable(Context context) throws Exception {
    ByteArrayOutputStream fileNameFunz = new ByteArrayOutputStream();
    ModdedZipArchiveOutputStream zaos = new ModdedZipArchiveOutputStream(fileNameFunz);
    ZipArchiveEntry zae = new ZipArchiveEntry("test_file");
    byte [] originalData = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".getBytes();
    byte [] modifiedData = "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB".getBytes();
    zae.setMethod(ZipEntry.STORED);
    zae.setSize(originalData.length);
    CRC32 checker = new CRC32();
    checker.update(originalData);
    zae.setCrc(checker.getValue());
    zaos.putArchiveEntry(zae, originalData);
    zaos.write(originalData);
    zaos.closeArchiveEntry();
    zaos.writeRaw(modifiedData, 0, modifiedData.length);

    for(int i = 0; i < originalData.length - modifiedData.length; i++){
        zaos.writeRaw(new byte[]{0}, 0, 1);
    }

    zaos.flush();

    List<ZipArchiveEntry> entries = new ArrayList<>();
    entries.add(zae);

    zaos.finish(entries, new ArrayList<ZipArchiveEntry>());

    byte [] testZip = fileNameFunz.toByteArray();

    // write the result to a file
    File outputDir = context.getCacheDir();
    File badZip = File.createTempFile("prefix", "extension", outputDir);
    badZip.deleteOnExit();
    FileOutputStream outstream = new FileOutputStream(badZip);
    outstream.write(testZip);
    outstream.close();

    // see if we can still handle it
    ZipFile bad = new ZipFile(badZip);
    if(bad.size() != 1)
        throw new ZipException("Unexpected number of entries");

    ZipEntry ze = bad.entries().nextElement();
    DataInputStream dis = new DataInputStream(bad.getInputStream(ze));
    byte [] buf = new byte[(int)ze.getSize()];
    dis.readFully(buf);
    bad.close();
    return new String(buf).startsWith("AAAAAAAAAAAAAAA");
}
 
開發者ID:AndroidVTS,項目名稱:android-vts,代碼行數:50,代碼來源:ZipBug9950697.java


注:本文中的org.apache.commons.compress.archivers.zip.ZipArchiveEntry.setCrc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。