Unzip will not work on some archives

조회 수: 30 (최근 30일)
Matthew Rademacher
Matthew Rademacher 2023년 4월 11일
편집: Matthew Rademacher 2023년 4월 26일
When I run the unzip function, it will fail on certain archives. What really confuses me is that I can extract an archive's contents manually via the gui (right click an archive -> unzip).
Error message is simply "Invalid ZIP file:
C:\users\Desktop\myzipfile.zip"
The zip file is not invalid, and it is not corrupted
  댓글 수: 4
Matthew Rademacher
Matthew Rademacher 2023년 4월 24일
@Walter Roberson, using your suggestions I've learned that my problem is that unzip fails while trying to extract entries created with the deflate64 method. (which lines up with the problem seen a decade ago here: Matlab fails to unzip large files - MATLAB Answers - MATLAB Central (mathworks.com)).
With that knowledge, do I have any options?

댓글을 달려면 로그인하십시오.

채택된 답변

chrisw23
chrisw23 2023년 4월 12일
편집: Walter Roberson 2023년 4월 14일
try to use .net Functionality (Windows OS assumed)
asm = NET.addAssembly("System.IO.Compression");
import System.IO.Compression.ZipFileExtensions.*
ZipFileExtensions.ExtractToFile(...
ZipFileExtensions.ExtractToDirectory(...
% search for system.io.compression.zipfileextensions.extracttodirectory to get the argument list
  댓글 수: 11
Matthew Rademacher
Matthew Rademacher 2023년 4월 25일
The code I posted above will successfully create a java Deflate64InputStream object- but I am struggling to actually do anything with it. I am new to both java and File Input Streams, so please forgive my ignorance.
Not sure if this is relevant, but I can read the JavaFileInputStream byte-by-byte, it's only the Deflate64 inputstream that yeilds an error from the "read" method.
Matthew Rademacher
Matthew Rademacher 2023년 4월 26일
편집: Matthew Rademacher 2023년 4월 26일
I am not a huge fan of this implementation at all but I do have a workaround. I have to install 7zip and execute the 7z.exe executable from command line using the "!" operator. Kind of stinky that you need 7zip installed but I got stuck on the java implementation and need something that works. Here zpath is the path where the 7z.exe file is located (C:\Program Files\7-Zip for me), Archive is the .zip archive compressed with deflate64, and targetpath is the path you want the file to be on.
cmdstring = sprintf('!"%s7z.exe" x %s -o%s -y',zpath,Archive,TargetPath)
eval(cmdstring)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by