mirror of
https://github.com/0x5eal/luau-unzip.git
synced 2025-04-19 05:03:46 +01:00
chore(examples): update example to use test file
This commit is contained in:
parent
3e9b3a3d94
commit
e7a654d530
1 changed files with 2 additions and 2 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue