Skip to content

Instantly share code, notes, and snippets.

@nadar71
Forked from peter-mach/unzip_folder.lua
Created January 26, 2017 13:32
Show Gist options
  • Save nadar71/353b140d937c93341f77eade03b4289c to your computer and use it in GitHub Desktop.
Save nadar71/353b140d937c93341f77eade03b4289c to your computer and use it in GitHub Desktop.
Unzipping the compressed folder with CoronaSDK zip plugin
local zip = require 'plugin.zip'
local zipFileName = 'zippedFolder.zip'
local function unzipListener( event )
print('unzipping complete')
end
local unzipOptions = {
zipFile = event.response.fileName,
zipBaseDir = system.TemporaryDirectory,
dstBaseDir = system.DocumentsDirectory,
files = {},
listener = unzipListener
}
local function listZipListener( event )
local fileList = {}
for i,v in ipairs(event.response) do
fileList[#fileList+1] = v.file
end
unzipOptions.files = fileList
print('zip listing complete')
zip.uncompress( unzipOptions )
end
local listZipOptions = {
zipFile = zipFileName,
zipBaseDir = system.TemporaryDirectory,
listener = listZipListener
}
zip.list( listZipOptions )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment