Zip:read(path) method
Reads an entry in memory at the given path/name in the Zip archive. The Zip archive should have been previously opened in "read" mode.
Parameters
path
A string representing the path and/or the name of the entry in the Zip archive.
Return value
Returns a Buffer value with the entry content.Returns false if any error occured. You can check the Zip.error property to get the error message.
Example
-- read an entry in a zip archive and print its content
local compression = require "compression"
local console = require "console"
local archive_name = console.readln("Enter name of the zip archive: ")
local entry_name = console.readln("Enter an entry to print its content: ")
console.writecolor("cyan", entry_name, "from", archive_name, ":\n")
-- open the zip archive in "read" mode
local z = compression.Zip(archive_name)
-- read the entry content or throws an error if false
local content = z:read(entry_name) or error(z.error)
-- prints the content in hexadecimal
console.write(content:encode("hex"))