xXm0dzXx

Test .Zip Reader

Sep 3rd, 2012
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. function ExtractZipAndCopyFiles(zipPath, zipFilename, destinationPath)
  2. local zfile, err = zip.open(zipPath .. zipFilename)
  3.  
  4. -- iterate through each file insize the zip file
  5. for file in zfile:files() do
  6.     local currFile, err = zfile:open(file.filename)
  7.     local currFileContents = currFile:read("*a") -- read entire contents of current file
  8.     local hBinaryOutput = io.open(destinationPath .. file.filename, "wb")
  9.  
  10.     -- write current file inside zip to a file outside zip
  11.     if(hBinaryOutput)then
  12.         hBinaryOutput:write(currFileContents)
  13.         hBinaryOutput:close()
  14.     end
  15.     currFile.close()
  16. end
  17.  
  18. zfile:close()
  19. end
Advertisement
Add Comment
Please, Sign In to add comment