You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting "Error 79 - Inappropriate file type or format." on macOS Montery if I try to extract a file that's created using ZipOutPutStream and that contains empty folders.
On Windows 11, using the built in Zip utility, no error is shown. When using 7zip on Windows, the files and folders are successfully extracted, but 7zip warns me about "Header errors". On Mac, I was able to successfully extract the empty folders using a tool called "The Unarchiver".
I'm not sure if I'm adding the empty folder zip entries correct. Basically, I'm just looping over all the empty folders that should be added to the zip first, and then, in a secondary loop, I'm adding all the actual files.
A folder is added like this, where the filename is the folder path with a trailing "/":
.....
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try(ZipOutputStream zos = initializeZipOutputStream(bos, input.isEncryptZip(), password )) {
// Add all empty folders first
for (String emptyFolder : emptyFolders){
zipParameters.setFileNameInZip(emptyFolder);
zos.putNextEntry(zipParameters);
zos.closeEntry();
}
..... loop adding actual files here (code removed. Is just like the example in the readme).
// closing the stream and uploading to AWS S3
zos.close();
s3Client.putObject(putObjectRequest, RequestBody.fromBytes(bos.toByteArray()));
}
.....
Attached an example Zip generated by Zip4j with one empty folder and one folder with a file.
I'm getting "Error 79 - Inappropriate file type or format." on macOS Montery if I try to extract a file that's created using ZipOutPutStream and that contains empty folders.
On Windows 11, using the built in Zip utility, no error is shown. When using 7zip on Windows, the files and folders are successfully extracted, but 7zip warns me about "Header errors". On Mac, I was able to successfully extract the empty folders using a tool called "The Unarchiver".
I'm not sure if I'm adding the empty folder zip entries correct. Basically, I'm just looping over all the empty folders that should be added to the zip first, and then, in a secondary loop, I'm adding all the actual files.
A folder is added like this, where the filename is the folder path with a trailing "/":
Relevant part of the code:
Attached an example Zip generated by Zip4j with one empty folder and one folder with a file.
futureconf2021-20220309T1159AM.zip
The text was updated successfully, but these errors were encountered: