zip-rs/zip-old

Read only a file in the zip file without decompressing it

cn-hew opened this issue · 2 comments

hi~,
How do I get the file name without a path in a zip? Is there a way to do this? Can I directly read the matching file in the subdirectory based on the file name without caring which directory it is in?

You can inspect the files that you find in an archive with ZipArchive::file_names. You can implement any searching algorithm you like through that.

Here, it looks like you might use rs let file_name = ...; for entry in archive.file_names() { if entry.ends_with(file_name) { // handle the archive.by_name(entry) } }

You can inspect the files that you find in an archive with ZipArchive::file_names. You can implement any searching algorithm you like through that.

Here, it looks like you might use rs let file_name = ...; for entry in archive.file_names() { if entry.ends_with(file_name) { // handle the archive.by_name(entry) } }

thanks bro i used your method it really works I'm not familiar with rust