Unzip will not work on some archives

29 次查看(过去 30 天)
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