How to tell if a “ZipArchiveEntry” is directory?

Seems like I really do tend to answer my own questions.

Anyway, the answer is straight forward:

If ZipArchiveEntry is a directory it will have its FullName property ending with “https://stackoverflow.com/” (e.g. “some_dir/”) and its Name property will be empty string (“”).

If only someone cared to put that info in the documentation …

Oh, and there is a catch:
If a directory contains files, there does not have to be a separate ZipArchiveEntry for it.
So, if you are looking for a specific directory you cannot just look for one ZipArchiveEntry with empty Name or with “https://stackoverflow.com/” at the end of FullName – you have to parse the whole tree (FullName for each ZipArchiveEntry).

Luckily I had only to check if there is a single common directory for all entries (FullName properties of all ZipArchiveEntry items shoud start with the same string in the form of “folder_name/”).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)