chore(examples): update example to use test file

This commit is contained in:
Erica Marigold 2025-01-06 05:51:40 +00:00
parent 3e9b3a3d94
commit e7a654d530
Signed by: DevComp
GPG key ID: 429EF1C337871656

View file

@ -2,14 +2,14 @@ local fs = require("@lune/fs")
local stdio = require("@lune/stdio") local stdio = require("@lune/stdio")
local zip = require("../lib") local zip = require("../lib")
local file = fs.readFile("test.zip") local file = fs.readFile("tests/data/files_and_dirs.zip")
local reader = zip.load(buffer.fromstring(file)) local reader = zip.load(buffer.fromstring(file))
print("Directory structure:") print("Directory structure:")
reader:walk(function(entry, depth) reader:walk(function(entry, depth)
local prefix = string.rep(" ", depth) local prefix = string.rep(" ", depth)
local suffix = if not entry.isDirectory local suffix = if not entry.isDirectory
then string.format(" (%d bytes), content: %s", entry.size, stdio.format(reader:extract(entry) :: string)) then string.format(" (%d bytes), content: %s", entry.size, reader:extract(entry, { isString = true }) :: string)
else "" else ""
print(prefix .. entry.name .. suffix) print(prefix .. entry.name .. suffix)
end) end)