Skip to content

class ZFile

😱 Types incomplete or incorrect? 🙏 Please contribute!


methods


ZFile.close


function ZFile.close() -> success boolean

Close a zfile opened by zip.open.

Example:

local z_file = zip.open('../test.zip')
assert(z_file)
local success = z_file:close()
assert(success == true, success)

Reference:

ZFile.files


function ZFile.files() ->  fun() -> ZInternalFileInfo

Return an iterator function that returns a new table containing informations about the current file.

Example:

local z_file = zip.open('../test.zip')
assert(z_file)

for info in z_file:files() do
  assert(info.filename)
  assert(info.compression_method)
  assert(info.compressed_size)
  assert(info.uncompressed_size)
end

Reference:

ZFile.open


function ZFile.open(filename: string)
 ->  ZInternalFile?
 -> err string?

Open a file that is stored inside the zip file opened by zip.open.

The filename may contain the full path of the file contained inside the zip. The directory separator must be '/'. Unlike f:open, there is no mode parameter, as the only supported mode is "read".

Example:

local z_file = zip.open('test.zip')
assert(z_file)
local _, err = z_file:open('xxx.xxx')
assert(err == 'could not open file `xxx.xxx\'')

local z_internal_file, err = z_file:open('Hello-world.txt')
assert(z_internal_file)
assert(err == nil)

Reference: