Java Code Examples for net.lingala.zip4j.model.FileHeader#getZip64ExtendedInfo()

The following examples show how to use net.lingala.zip4j.model.FileHeader#getZip64ExtendedInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractModifyFileTask.java    From zip4j with Apache License 2.0 6 votes vote down vote up
void updateOffsetsForAllSubsequentFileHeaders(ZipModel zipModel, FileHeader fileHeaderModified, long offsetToAdd) throws ZipException {
  int indexOfFileHeader = HeaderUtil.getIndexOfFileHeader(zipModel, fileHeaderModified);

  if (indexOfFileHeader == -1) {
    throw new ZipException("Could not locate modified file header in zipModel");
  }

  List<FileHeader> allFileHeaders = zipModel.getCentralDirectory().getFileHeaders();

  for (int i = indexOfFileHeader + 1; i < allFileHeaders.size(); i++) {
    FileHeader fileHeaderToUpdate = allFileHeaders.get(i);
    fileHeaderToUpdate.setOffsetLocalHeader(fileHeaderToUpdate.getOffsetLocalHeader() + offsetToAdd);

    if (zipModel.isZip64Format()
        && fileHeaderToUpdate.getZip64ExtendedInfo() != null
        && fileHeaderToUpdate.getZip64ExtendedInfo().getOffsetLocalHeader() != -1) {

      fileHeaderToUpdate.getZip64ExtendedInfo().setOffsetLocalHeader(
          fileHeaderToUpdate.getZip64ExtendedInfo().getOffsetLocalHeader() + offsetToAdd
      );
    }
  }
}
 
Example 2
Source File: Unzip.java    From AndroidZip with Apache License 2.0 6 votes vote down vote up
private long calculateTotalWork(ArrayList fileHeaders) throws ZipException {
	
	if (fileHeaders == null) {
		throw new ZipException("fileHeaders is null, cannot calculate total work");
	}
	
	long totalWork = 0;
	
	for (int i = 0; i < fileHeaders.size(); i++) {
		FileHeader fileHeader = (FileHeader)fileHeaders.get(i);
		if (fileHeader.getZip64ExtendedInfo() != null && 
				fileHeader.getZip64ExtendedInfo().getUnCompressedSize() > 0) {
			totalWork += fileHeader.getZip64ExtendedInfo().getCompressedSize();
		} else {
			totalWork += fileHeader.getCompressedSize();
		}
		
	}
	
	return totalWork;
}
 
Example 3
Source File: HeaderUtil.java    From zip4j with Apache License 2.0 5 votes vote down vote up
public static long getTotalUncompressedSizeOfAllFileHeaders(List<FileHeader> fileHeaders) {
  long totalUncompressedSize = 0;
  for (FileHeader fileHeader : fileHeaders) {
    if (fileHeader.getZip64ExtendedInfo() != null &&
        fileHeader.getZip64ExtendedInfo().getUncompressedSize() > 0) {
      totalUncompressedSize += fileHeader.getZip64ExtendedInfo().getUncompressedSize();
    } else {
      totalUncompressedSize += fileHeader.getUncompressedSize();
    }
  }
  return totalUncompressedSize;
}