I think your code is perfect. I suspect your zip file does not contain directories. They do not need!
For example, a zip file created using "a / b / c / d.txt" is created here. When I originally created it, directories were added to the zip file:
$ unzip -l a.zip Archive: a.zip Length Date Time Name
But then I deleted the directories from the zip index:
$ zip -d a.zip a/b/c deleting: a/b/c/ $ zip -d a.zip a/b deleting: a/b/ $ zip -d a.zip a deleting: a/
And now, when I have listed its contents, I'm pretty sure that only the file will appear. No catalogs:
$ unzip -l a.zip Archive: a.zip Length Date Time Name
Note: when I unzipped the same file, it created the a / b / c / directory before extracting the d.txt file, even though the zip index itself did not contain directories. Thus, it seems that entries in zip files are completely optional.
source share