Unzip ZIP Archives In Luau?

Is there an already-existing module for unzipping ZIP archive files using Luau? I’ve looked on Google but they’re all in vanilla Lua 5.x and require the zip library (the zip library is written in C and is >800 lines long, there’s no way I’m manually converting that much code to Lua).

This is for a new feature for a plugin (StudioCLI) that will use PromptImportFile.

And before this comes up, I do not want to use an external webserver at all.

You mean outside of Roblox? The module might work. Inside of Roblox you might need to write your own.

Inside of Roblox.

Picture this:

  1. Plugin prompts you to import a ZIP archive
  2. The plugin unzips the imported ZIP archive and recreates the files all inside the plugin, not dependent on a webserver to receive the zip, parse it, and send back Lua-readable data (json)

There’s no way for Lua or Luau to access any functionality of the OS to manage files. As far as I’m aware, this would not be possible with Roblox without the use of that external web server. The best bet here is to make a feature request for APIs that help with handling ZIP Archives.

This is for a plugin he’s making and they do have access to system files (although it prompts the user to select files for obvious reasons.)

3 Likes

Take a look at the zzlib repository. It’s a pure Lua implementation. I haven’t ever used it (just found it), so I don’t know if/how it works, but might at least be a good starting point.

You will have to modify it a bit. For instance, in the main zzlib.lua file, it’s trying to dynamically load its core module based on the Lua version. Instead, just grab the inflate-bit32 module, since that’s what we have in Luau.

Also, I can only imagine that deflating in Lua is going to be pretty slow. Just FYI.

5 Likes

Thanks, I’ll try it out tomorrow when I have the time.

EDIT: Yup, it worked perfectly!

1 Like

Can you give example of how it works?