Skip to content

Empty directories are extracted as zero-length files #364

@natep

Description

@natep

Summary

Some of the zip files produced by our app include empty directories. I think by default those wouldn't be included in the archive, but we explicitly add them when we create the zip files using SSZipArchive.

When extracting these zip files using ZipFoundation, those empty directories are extracted as zero-length files instead. Digging into the bits set for the external attributes for those entries, I think ZipFoundation is technically correct that they are marked as files instead of directories (as best I could figure out with my limited knowledge of the zip format). So probably that is a bug in SSZipArchive.

However, using the system unzip on Mac, it does properly extract them as directories. I'm guessing that instead of looking at the attributes, it is basing that on the trailing slash at the end of the path.

Given that (as far as I know) it is not legal for a filename to contain a slash on any platform, would you consider changing the extraction logic so that any file entry with a trailing slash is extracted as a directory?

Steps to Reproduce

Use ZipFoundation to unzip this zip file:

empty_dirs.zip

Expected Results

The resulting unzipped files include empty directories for all entries that end in a slash.

Actual Results

Entries that end in a slash are extracted as zero-length files.

Regression & Version

Occurs in 0.9.19

Related Link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions