zip.uncompress()

Type Function
Library zip.*
Return value none
Revision 2018.3333
Keywords zip, uncompress
See also zip.compress()
zip.list()

Overview

Extracts (uncompresses) all files from a zip archive.

Syntax

zip.uncompress( options )
options (required)

Table. A table of options for the function call — see the next section for details.

Options Reference

zipFile (required)

String. The zip file to extract files from.

zipBaseDir (required)

Constant. The base directory containing the zip archive.

dstBaseDir (required)

Constant. The destination folder to extract files to.

files (optional)

Array. A table specifying file names to extract from the archive. By default all files will be extracted.

password (optional)

String. The password which was used to encrypt the zip file (standard Zip 2.0 encryption).

listener (required)

Listener. The listener function invoked at the end of the operation.

Example

local zip = require( "plugin.zip" )

local function zipListener( event )

    if ( event.isError ) then
        print( "Error!" )
    else
        print ( event["type"] )  --> uncompress
        print ( event.response[1] )  --> space.jpg
        print ( event.response[2] )  --> space1.jpg
    end
end

-- Attempts to uncompress all files from "test.zip" to a destination folder
local zipOptions =
{
    zipFile = "test.zip",
    zipBaseDir = system.ResourceDirectory,
    dstBaseDir = system.DocumentsDirectory,
    files = { "space.jpg", "space1.jpg" },
    listener = zipListener
}
zip.uncompress( zipOptions )