本文整理了Java中net.lingala.zip4j.model.ZipModel.isSplitArchive()
方法的一些代码示例,展示了ZipModel.isSplitArchive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipModel.isSplitArchive()
方法的具体详情如下:
包路径:net.lingala.zip4j.model.ZipModel
类名称:ZipModel
方法名:isSplitArchive
暂无
代码示例来源:origin: net.lingala.zip4j/zip4j
/**
* Checks if the zip file is a split archive
* @return true if split archive, false if not
* @throws ZipException
*/
public boolean isSplitArchive() throws ZipException {
if (zipModel == null) {
readZipInfo();
if (zipModel == null) {
throw new ZipException("Zip Model is null");
}
}
return zipModel.isSplitArchive();
}
代码示例来源:origin: com.github.axet/zip4j
/**
* Checks if the zip file is a split archive
* @return true if split archive, false if not
* @throws ZipException
*/
public boolean isSplitArchive() throws ZipException {
if (zipModel == null) {
readZipInfo();
if (zipModel == null) {
throw new ZipException("Zip Model is null");
}
}
return zipModel.isSplitArchive();
}
代码示例来源:origin: net.lingala.zip4j/zip4j
protected void checkAndReadAESMacBytes() throws IOException {
if (isAESEncryptedFile) {
if (decrypter != null && decrypter instanceof AESDecrypter) {
if (((AESDecrypter)decrypter).getStoredMac() != null) {
//Stored mac already set
return;
}
byte[] macBytes = new byte[InternalZipConstants.AES_AUTH_LENGTH];
int readLen = -1;
readLen = raf.read(macBytes);
if (readLen != InternalZipConstants.AES_AUTH_LENGTH) {
if (unzipEngine.getZipModel().isSplitArchive()) {
raf.close();
raf = unzipEngine.startNextSplitFile();
int newlyRead = raf.read(macBytes, readLen, InternalZipConstants.AES_AUTH_LENGTH - readLen);
readLen += newlyRead;
} else {
throw new IOException("Error occured while reading stored AES authentication bytes");
}
}
((AESDecrypter)unzipEngine.getDecrypter()).setStoredMac(macBytes);
}
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private long calculateTotalWorkForMergeOp(ZipModel zipModel) throws ZipException {
long totSize = 0;
if (zipModel.isSplitArchive()) {
int totNoOfSplitFiles = zipModel.getEndCentralDirRecord().getNoOfThisDisk();
String partFile = null;
String curZipFile = zipModel.getZipFile();
int partNumber = 0;
for (int i = 0; i <= totNoOfSplitFiles; i++) {
if (partNumber == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (partNumber >= 9) {
partFile = curZipFile.substring(0, curZipFile.lastIndexOf(".")) + ".z" + (partNumber+ 1);
} else{
partFile = curZipFile.substring(0, curZipFile.lastIndexOf(".")) + ".z0" + (partNumber+ 1);
}
}
totSize += Zip4jUtil.getFileLengh(new File(partFile));
}
}
return totSize;
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private RandomAccessFile createFileHandler(String mode) throws ZipException {
if (this.zipModel == null || !Zip4jUtil.isStringNotNullAndNotEmpty(this.zipModel.getZipFile())) {
throw new ZipException("input parameter is null in getFilePointer");
}
try {
RandomAccessFile raf = null;
if (zipModel.isSplitArchive()) {
raf = checkSplitFile();
} else {
raf = new RandomAccessFile(new File(this.zipModel.getZipFile()), mode);
}
return raf;
} catch (FileNotFoundException e) {
throw new ZipException(e);
} catch (Exception e) {
throw new ZipException(e);
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
private RandomAccessFile checkSplitFile() throws ZipException {
if (zipModel.isSplitArchive()) {
int diskNumberStartOfFile = fileHeader.getDiskNumberStart();
currSplitFileCounter = diskNumberStartOfFile + 1;
代码示例来源:origin: com.github.axet/zip4j
private long calculateTotalWorkForMergeOp(ZipModel zipModel) throws ZipException {
long totSize = 0;
if (zipModel.isSplitArchive()) {
int totNoOfSplitFiles = zipModel.getEndCentralDirRecord().getNoOfThisDisk();
NativeStorage partFile = null;
NativeStorage curZipFile = zipModel.getZipFile();
String curZipFileName = curZipFile.getName();
int partNumber = 0;
for (int i = 0; i <= totNoOfSplitFiles; i++) {
if (partNumber == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
partFile = zipModel.getZipFile();
} else {
if (partNumber >= 9) {
partFile = curZipFile.getParent().open(curZipFileName.substring(0, curZipFileName.lastIndexOf(".")) + ".z" + (partNumber+ 1));
} else{
partFile = curZipFile.getParent().open(curZipFileName.substring(0, curZipFileName.lastIndexOf(".")) + ".z0" + (partNumber+ 1));
}
}
totSize += Zip4jUtil.getFileLengh(partFile);
}
}
return totSize;
}
}
代码示例来源:origin: com.github.axet/zip4j
/**
* Internal method to add a folder to the zip file.
* @param path
* @param parameters
* @param checkSplitArchive
* @throws ZipException
*/
private void addFolder(NativeStorage path, ZipParameters parameters,
boolean checkSplitArchive) throws ZipException {
checkZipModel();
if (this.zipModel == null) {
throw new ZipException("internal error: zip model is null");
}
if (checkSplitArchive) {
if (this.zipModel.isSplitArchive()) {
throw new ZipException("This is a split archive. Zip file format does not allow updating split/spanned files");
}
}
ZipEngine zipEngine = new ZipEngine(zipModel);
zipEngine.addFolderToZip(path, parameters, progressMonitor, runInThread);
}
代码示例来源:origin: net.lingala.zip4j/zip4j
/**
* Internal method to add a folder to the zip file.
* @param path
* @param parameters
* @param checkSplitArchive
* @throws ZipException
*/
private void addFolder(File path, ZipParameters parameters,
boolean checkSplitArchive) throws ZipException {
checkZipModel();
if (this.zipModel == null) {
throw new ZipException("internal error: zip model is null");
}
if (checkSplitArchive) {
if (this.zipModel.isSplitArchive()) {
throw new ZipException("This is a split archive. Zip file format does not allow updating split/spanned files");
}
}
ZipEngine zipEngine = new ZipEngine(zipModel);
zipEngine.addFolderToZip(path, parameters, progressMonitor, runInThread);
}
代码示例来源:origin: com.github.axet/zip4j
protected void checkAndReadAESMacBytes() throws IOException {
if (isAESEncryptedFile) {
if (decrypter != null && decrypter instanceof AESDecrypter) {
if (((AESDecrypter)decrypter).getStoredMac() != null) {
//Stored mac already set
return;
}
byte[] macBytes = new byte[InternalZipConstants.AES_AUTH_LENGTH];
int readLen = -1;
readLen = raf.read(macBytes);
if (readLen != InternalZipConstants.AES_AUTH_LENGTH) {
if (unzipEngine.getZipModel().isSplitArchive()) {
raf.close();
raf = unzipEngine.startNextSplitFile();
int newlyRead = raf.read(macBytes, readLen, InternalZipConstants.AES_AUTH_LENGTH - readLen);
readLen += newlyRead;
} else {
throw new IOException("Error occured while reading stored AES authentication bytes");
}
}
((AESDecrypter)unzipEngine.getDecrypter()).setStoredMac(macBytes);
}
}
}
代码示例来源:origin: com.github.axet/zip4j
private NativeFile checkSplitFile() throws ZipException {
if (zipModel.isSplitArchive()) {
int diskNumberStartOfFile = fileHeader.getDiskNumberStart();
currSplitFileCounter = diskNumberStartOfFile + 1;
代码示例来源:origin: net.lingala.zip4j/zip4j
/**
* Removes the file provided in the input file header from the zip file.
* If zip file is a split zip file, then this method throws an exception as
* zip specification does not allow for updating split zip archives.
* @param fileHeader
* @throws ZipException
*/
public void removeFile(FileHeader fileHeader) throws ZipException {
if (fileHeader == null) {
throw new ZipException("file header is null, cannot remove file");
}
if (zipModel == null) {
if (Zip4jUtil.checkFileExists(file)) {
readZipInfo();
}
}
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file format does not allow updating split/spanned files");
}
ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
archiveMaintainer.initProgressMonitorForRemoveOp(zipModel, fileHeader, progressMonitor);
archiveMaintainer.removeZipFile(zipModel, fileHeader, progressMonitor, runInThread);
}
代码示例来源:origin: com.github.axet/zip4j
/**
* Removes the file provided in the input file header from the zip file.
* If zip file is a split zip file, then this method throws an exception as
* zip specification does not allow for updating split zip archives.
* @param fileHeader
* @throws ZipException
*/
public void removeFile(FileHeader fileHeader) throws ZipException {
if (fileHeader == null) {
throw new ZipException("file header is null, cannot remove file");
}
if (zipModel == null) {
if (Zip4jUtil.checkFileExists(file)) {
readZipInfo();
}
}
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file format does not allow updating split/spanned files");
}
ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
archiveMaintainer.initProgressMonitorForRemoveOp(zipModel, fileHeader, progressMonitor);
archiveMaintainer.removeZipFile(zipModel, fileHeader, progressMonitor, runInThread);
}
代码示例来源:origin: com.github.axet/zip4j
private NativeFile createFileHandler() throws ZipException {
if (this.zipModel == null || !Zip4jUtil.isStringNotNullAndNotEmpty(this.zipModel.getZipFile())) {
throw new ZipException("input parameter is null in getFilePointer");
}
try {
NativeFile raf = null;
if (zipModel.isSplitArchive()) {
raf = checkSplitFile();
} else {
raf = this.zipModel.getZipFile().read();
}
return raf;
} catch (FileNotFoundException e) {
throw new ZipException(e);
} catch (Exception e) {
throw new ZipException(e);
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file format does not allow updating split/spanned files");
代码示例来源:origin: com.github.axet/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file format does not allow updating split/spanned files");
代码示例来源:origin: net.lingala.zip4j/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
代码示例来源:origin: com.github.axet/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
代码示例来源:origin: net.lingala.zip4j/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
代码示例来源:origin: com.github.axet/zip4j
if (zipModel.isSplitArchive()) {
throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");
内容来源于网络,如有侵权,请联系作者删除!