Как извлечь файлы из zip-файла с помощью Lua?

Как извлечь файлы с помощью Lua?

Обновление: теперь у меня есть следующий код, но он падает каждый раз, когда достигает конца функции, но успешно извлекает все файлы и помещает их в нужное место.

require "zip"

function ExtractZipAndCopyFiles(zipPath, zipFilename, destinationPath)
    local zfile, err = zip.open(zipPath .. zipFilename)

    -- iterate through each file insize the zip file
    for file in zfile:files() do
        local currFile, err = zfile:open(file.filename)
        local currFileContents = currFile:read("*a") -- read entire contents of current file
        local hBinaryOutput = io.open(destinationPath .. file.filename, "wb")

        -- write current file inside zip to a file outside zip
        if(hBinaryOutput)then
            hBinaryOutput:write(currFileContents)
            hBinaryOutput:close()
        end
    end

    zfile:close()
end
-- call the function
ExtractZipAndCopyFiles("C:\\Users\\bhannan\\Desktop\\LUA\\", "example.zip", "C:\\Users\\bhannan\\Desktop\\ZipExtractionOutput\\")

Почему он падает каждый раз, когда достигает конца?

Ответы на вопрос(0)

Ваш ответ на вопрос