Skip to main content

Unzip a ZIP file (file.unzip)

Declaration

ok, err = file.unzip(zipPath, destDir [, password])

Parameters

  • zipPath
    String. Absolute path of the ZIP file to extract.
  • destDir
    String. Destination directory to extract into.
  • password
    String. Optional. Provide if the ZIP is password-protected.

Returns

  • ok
    Boolean. true if success, false if failure.
  • err
    String. Error message when operation fails.

Notes

Extract a ZIP file to a target directory.
Extracted files are set to permission 0755. Owner UID is 501 and group GID is 501. Available in versions after 2025-09-14.

Examples

local ok, err = file.unzip(XXT_SCRIPTS_PATH.."/archive.zip", XXT_SCRIPTS_PATH.."/unzipped", "123456")
if not ok then
sys.alert("Unzip failed: "..err)
else
sys.alert("Unzip succeeded: "..XXT_SCRIPTS_PATH.."/unzipped")
end
-- Without password
local ok, err = file.unzip(XXT_SCRIPTS_PATH.."/project.zip", XXT_SCRIPTS_PATH.."/project")
if not ok then
sys.alert("Unzip failed: "..err)
end

Note: Uses sys.alert