On 02/07/2021 04.14, Andrew Poulos wrote:
> Users can upload a archive (zip) to the server. On the server I can use
> extractTo to extract the archive's contents.
> The problem I have is that users should create an archive of an entire
> directory and not just the directory's contents (so that when the
> archive is extracted the contents will be in a directory.)
> How can I test whether all the files, and any sub-directories within an
> archive, are within one directory?
You will need to use the getNameIndex to list the files
> If they are within one directory I would also like the directory's name.
you would use dirname to figure out the path, you can use the level to
get the root.
You can store the first files root directory in a variable, then check
if the next file has the same root as the previous one, if they differ,
than you know there is multiple directories. If the variable value is
empty, then you have files directly in the root.