-
Notifications
You must be signed in to change notification settings - Fork 375
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
Directories are ignored in zip file #419
Comments
Same issue |
Likewise, I tried to list all the child entries out of a particular directory inside the zip archive.
But it didn't work. When I went debugging, I found that I think it's normal for directories to not show up as distinct "entries" in the zip archive. Maybe there's multiple ways to represent this in an archive, but certainly I'm used to seeing entries for regular files only. So this approach taken by adm-zip of first getting the directory "entry" is just plain not going to work. I worked around it by iterating over all the entries and testing for the directory prefix, using code like the below. Not ideal but right now I think it's the best we can do. /*
* Get a list of regular file entries under a directory.
*
* All descendants of the directory are returned, regardless of depth.
*/
export function getChildEntries(zip: Zip, dirName: string): ZipEntry[] {
let prefix = dirName;
if (!prefix.endsWith('/')) {
prefix += '/';
}
const entries = zip.getEntries();
if (!entries) {
return [];
}
// seems like `isDirectory` can never be true anyway, but just to be safe ...
return entries.filter(x => !x.isDirectory && x.entryName.startsWith(prefix));
} |
I've got a zip file created from https://makeappicon.com. It consists of three subdirectories each containing some image files and folders.
When opening this .zip file with adm-zip (v0.5.9) and reading the
getEntries()
contents, there are no directories, just files.However when using
extractAllTo()
, the folder structure is preserved and files are extracted into subdirectories.How to I get the files from within one subdirectory? Using
extractEntryTo("ios/", false, true)
returns an entry not found error.The text was updated successfully, but these errors were encountered: