zip.uncompress()

Type Function
Library zip.*
Return value none
Revision 2017.3060
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.

listener (required)

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

Example

local zip = require( "plugin.zip" )

-- Attempts to uncompress all files from "test.zip" to a destination folder.

local function zipListener( event )

    if ( event.isError ) then
        print( "Error!" )
    else
        print( "event.name: " .. event.name )
        print( "event.type: " .. event.type )

        --example response
        --event.response = {
        --[1] = "space.jpg",
        --[2] = "space1.jpg",
        --}
    end
end

local zipOptions =
{
    zipFile = "test.zip",
    zipBaseDir = system.ResourceDirectory,
    dstBaseDir = system.DocumentsDirectory,
    files = { "space.jpg", "space1.jpg" },
    listener = zipListener
}
zip.uncompress( zipOptions )