Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset and size of entry in archive #113

Open
baszalmstra opened this issue Oct 22, 2023 · 1 comment
Open

Offset and size of entry in archive #113

baszalmstra opened this issue Oct 22, 2023 · 1 comment

Comments

@baszalmstra
Copy link
Contributor

Im working on reading zip files over http using http ranges. To do that correctly I first fetch the last couple of bytes from archive to read the central directory following by reading the bytes for a specific file.

However, this library does not provide me with the exact number of bytes for a single file.

I can use something along the lines of:

let entry = reader.file().entries().get(0).unwrap();
let offset = entry.header_offset();
// Get the size of the entry plus the header + size of the filename. We should also actually
// include bytes for the extra fields but we don't have that information.
let size = entry.entry().compressed_size() + 30 + entry.entry().filename().as_bytes().len();

but the computation of the size is fairly magical and incorrect if the header contains extra fields.

What would be a "nicer" way to get this information? Would it be possible to add a function that returns the total size of the file in the archive from a StoredZipEntry?

@startewho
Copy link
Contributor

may be add a heder_size() function,that can use
header_offset()+ heder_size()
get the offet in the archive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants