Closed zangloo closed 6 months ago
You can use by_name(name) != Err(ZipError::FileNotFound)
.
I just want check if the file is exists, if using by_name() and the file exists, it will create a reader, do seek, read header, calc the size, etc... . And i may check a file list existance for every file, then by using by_name, will cause a lot of useless operations.
A new method index_for_name
will release in version 1.1.1, with no side effects and taking an immutable borrow; then you'll be able to use index_for_name(name).is_some()
.
That's great. Thanks.
I'm writing a program, that need to check a lot of referenced files exists in the zip file without open it. If the zip containt a lot of files, the check will take a lot of time. I found the file_names() is collect the names of a map, so maybe add a funciton like
pub fn file_exists(name: &str)
will be much faster then iterate all file names.