On Monday, 3 February 2020 at 13:26:38 UTC, mark wrote:
I'm using std.zip.ZipArchive to read zip files, e.g.:
auto zip = new ZipArchive(read(filename));
// ...
foreach (name, member; zip.directory) {
if (name.endsWith('/')) // skip dirs
continue;
mkdirRecurse(dirName(name));
zip.expand(member);
write(name, member.expandedData());
}
As you can see, I am detecting directories with a crude test.
I really wish there was a method for this: and if there is,
could you give me the link 'cos I can't see one in the docs?
(BTW The code above is slightly simplified: the real code won't
unzip if there's an absolute path or .. present and also
ensures that all members are unzipped into a subdir even if the
zip has top-level names.)
ArchiveMember has "flags" field, perhaps it stores if it's a
directory?
If not, fileAttributes will have it but it looks it's OS specific.