user1543951
user1543951

Reputation: 23

How to unpack a .zip file with Lua?

How do you extract a .zip file with multiple subdirectories in Lua?

Yes, I know this, but I don't think it works with multiple subdirectories. I don`t see any function in LuaZip that would allow listing files in a directory inside the zip file. Any suggestsions?

I don`t know the directories' (those inside the zip) name, so I need to list them somehow.

Upvotes: 1

Views: 2395

Answers (1)

Oleg V. Volkov
Oleg V. Volkov

Reputation: 22431

After you open a zip with zfile = zip.open('file.zip'), scan it with for member in zfile:files(). member will contain full path of files inside zip, including all leading directories, separated with /. It is up to you to parse it, create directories in real filesystem and extract files to correct place.

If you need list of unique directories, just strip file name from all members and save remaining directories as keys to table.

Upvotes: 5

Related Questions