question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

-1 returned from ZipEntry.ExternalFileAttributes

See original GitHub issue

Steps to reproduce

  1. Zip a file on Linux using Info-Zip
  2. Unzip using the library
  3. Try to retrieve the file permissions int unixFilePermission = zipEntry.ExternalFileAttributes;

Expected behavior

unixFilePermission returns the right int value

Actual behavior

ExternalFileAttributes returns -1 for all extracted files (zip entry)

Version of SharpZipLib

1.3.3

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pikselcommented, Mar 23, 2022

Not anything I tried, but the central directory is at the very end, so you could make a custom stream wrapper that buffers the reads and permits seeking within the last BUFFER_SIZE bytes. That way you could just open the stream with ZipFile after the last entry has been read, iterate over the entries and just update the permissions.

I think that would work. Reading the data wouldn’t work of course, but as long as you allow the seeks, the iteration of the entries should work…

0reactions
emmaysparkcommented, Mar 22, 2022

Thanks In my case, I’m trying to extract and parse data immediately without needing to wait for the ZIP file to buffer. because of the structure of zip archive format, I believe zip permission cannot be retrieved in real-time.

Do you think there is a way to check the point to central directory to retrieve permission while I’m streaming a zip archive?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZipInputStream (Java SE 17 & JDK 17)
This class implements an input stream filter for reading files in the ZIP file format. Includes support for both compressed and uncompressed entries....
Read more >
Does a ZipEntry persist after a ZipFile is closed?
I currently have a plausible resource leak in my library due to the fact that I hold a ZipFile open so that the...
Read more >
mono/ZipEntry.cs at main
ZipFile and ZipInputStream will give you instances of this class as ... int externalFileAttributes = -1; // contains external attributes (os dependant).
Read more >
zipfile — Work with ZIP archives
Return a list containing a ZipInfo object for each member of the archive. The objects are in the same order as their entries...
Read more >
Class ZipEntry | SharpZipLib Help
This class represents an entry in a zip archive. This can be a file or a directory ZipFile and ZipInputStream will give you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found