style: apply stylua formatter

This commit is contained in:
Erica Marigold 2024-12-30 11:13:57 +00:00
parent 792682e46d
commit c2e638cbec
Signed by: DevComp
GPG key ID: 429EF1C337871656
6 changed files with 911 additions and 774 deletions

View file

@ -6,30 +6,31 @@ local reader = zip.load(buffer.fromstring(file))
print("Directory structure:")
reader:walk(function(entry, depth)
local prefix = string.rep(" ", depth)
local suffix = if not entry.isDirectory then string.format(" (%d bytes)", entry.size) else ""
print(prefix .. entry.name .. suffix)
local prefix = string.rep(" ", depth)
local suffix = if not entry.isDirectory then string.format(" (%d bytes)", entry.size) else ""
print(prefix .. entry.name .. suffix)
end)
print("\nContents of `/`:")
local assets = reader:listDirectory("/")
for _, entry in assets do
print(entry.name, if entry.isDirectory then "DIR" else entry.size)
if not entry.isDirectory then
local extracted = reader:extract(entry, { isString = true })
print("Content:", extracted)
end
print(entry.name, if entry.isDirectory then "DIR" else entry.size)
if not entry.isDirectory then
local extracted = reader:extract(entry, { isString = true })
print("Content:", extracted)
end
end
-- Get archive statistics
local stats = reader:getStats()
print(string.format([[
print(string.format(
[[
Archive stats:
Files: %d
Directories: %d
Total size: %d bytes]],
stats.fileCount,
stats.dirCount,
stats.totalSize
stats.fileCount,
stats.dirCount,
stats.totalSize
))

View file

@ -2,29 +2,29 @@ local CRC32_TABLE = table.create(256)
-- Initialize the lookup table and lock it in place
for i = 0, 255 do
local crc = i
for _ = 1, 8 do
if bit32.band(crc, 1) == 1 then
crc = bit32.bxor(bit32.rshift(crc, 1), 0xEDB88320)
else
crc = bit32.rshift(crc, 1)
end
end
CRC32_TABLE[i] = crc
local crc = i
for _ = 1, 8 do
if bit32.band(crc, 1) == 1 then
crc = bit32.bxor(bit32.rshift(crc, 1), 0xEDB88320)
else
crc = bit32.rshift(crc, 1)
end
end
CRC32_TABLE[i] = crc
end
table.freeze(CRC32_TABLE)
local function crc32(buf: buffer): number
local crc = 0xFFFFFFFF
local crc = 0xFFFFFFFF
for i = 0, buffer.len(buf) - 1 do
local byte = buffer.readu8(buf, i)
local index = bit32.band(bit32.bxor(crc, byte), 0xFF)
crc = bit32.bxor(bit32.rshift(crc, 8), CRC32_TABLE[index])
end
for i = 0, buffer.len(buf) - 1 do
local byte = buffer.readu8(buf, i)
local index = bit32.band(bit32.bxor(crc, byte), 0xFF)
crc = bit32.bxor(bit32.rshift(crc, 8), CRC32_TABLE[index])
end
return bit32.bxor(crc, 0xFFFFFFFF)
return bit32.bxor(crc, 0xFFFFFFFF)
end
return crc32

View file

@ -27,7 +27,7 @@ export type DataInner = {
dest: buffer,
destLen: number,
ltree: Tree,
ltree: Tree,
dtree: Tree,
}

View file

@ -270,8 +270,10 @@ function ZipReader.extract(self: ZipReader, entry: ZipEntry, options: Extraction
local optionsOrDefault: {
decompress: boolean,
isString: boolean,
skipValidation: boolean
} = if options then setmetatable(options, { __index = defaultOptions }) :: any else defaultOptions
skipValidation: boolean,
} = if options
then setmetatable(options, { __index = defaultOptions }) :: any
else defaultOptions
local pos = entry.offset
if buffer.readu32(self.data, pos) ~= SIGNATURES.LOCAL_FILE then

View file

@ -2,6 +2,80 @@ name = "0x5eal/unzip"
version = "0.1.0"
target = "luau"
[graph."jiwonz/dirs"."0.1.2 lune"]
resolved_ty = "standard"
[graph."jiwonz/dirs"."0.1.2 lune".target]
environment = "lune"
lib = "src/init.luau"
[graph."jiwonz/dirs"."0.1.2 lune".dependencies]
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
[graph."jiwonz/dirs"."0.1.2 lune".pkg_ref]
ref_ty = "pesde"
name = "jiwonz/dirs"
version = "0.1.2"
index_url = "https://github.com/daimond113/pesde-index"
[graph."jiwonz/dirs"."0.1.2 lune".pkg_ref.dependencies]
pathfs = [{ name = "jiwonz/pathfs", version = "^0.1.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
[graph."jiwonz/dirs"."0.1.2 lune".pkg_ref.target]
environment = "lune"
lib = "src/init.luau"
[graph."jiwonz/pathfs"."0.1.0 lune"]
resolved_ty = "standard"
[graph."jiwonz/pathfs"."0.1.0 lune".target]
environment = "lune"
lib = "init.luau"
[graph."jiwonz/pathfs"."0.1.0 lune".pkg_ref]
ref_ty = "pesde"
name = "jiwonz/pathfs"
version = "0.1.0"
index_url = "https://github.com/daimond113/pesde-index"
[graph."jiwonz/pathfs"."0.1.0 lune".pkg_ref.target]
environment = "lune"
lib = "init.luau"
[graph."lukadev_0/option"."1.2.0 lune"]
resolved_ty = "standard"
[graph."lukadev_0/option"."1.2.0 lune".target]
environment = "lune"
lib = "lib/init.luau"
[graph."lukadev_0/option"."1.2.0 lune".pkg_ref]
ref_ty = "pesde"
name = "lukadev_0/option"
version = "1.2.0"
index_url = "https://github.com/daimond113/pesde-index"
[graph."lukadev_0/option"."1.2.0 lune".pkg_ref.target]
environment = "lune"
lib = "lib/init.luau"
[graph."lukadev_0/result"."1.2.0 lune"]
resolved_ty = "standard"
[graph."lukadev_0/result"."1.2.0 lune".target]
environment = "lune"
lib = "lib/init.luau"
[graph."lukadev_0/result"."1.2.0 lune".pkg_ref]
ref_ty = "pesde"
name = "lukadev_0/result"
version = "1.2.0"
index_url = "https://github.com/daimond113/pesde-index"
[graph."lukadev_0/result"."1.2.0 lune".pkg_ref.target]
environment = "lune"
lib = "lib/init.luau"
[graph."lukadev_0/result"."1.2.0 luau"]
direct = ["result", { name = "lukadev_0/result", version = "^1.2.0" }, "standard"]
resolved_ty = "standard"
@ -19,3 +93,60 @@ index_url = "https://github.com/pesde-pkg/index"
[graph."lukadev_0/result"."1.2.0 luau".pkg_ref.target]
environment = "luau"
lib = "lib/init.luau"
[graph."pesde/stylua"."2.0.2 lune"]
direct = ["stylua", { name = "pesde/stylua", version = "^2.0.2", target = "lune" }, "dev"]
resolved_ty = "dev"
[graph."pesde/stylua"."2.0.2 lune".target]
environment = "lune"
bin = "init.luau"
[graph."pesde/stylua"."2.0.2 lune".dependencies]
"lukadev_0/option" = ["1.2.0 lune", "option"]
"lukadev_0/result" = ["1.2.0 lune", "result"]
"pesde/toolchainlib" = ["0.1.7 lune", "core"]
[graph."pesde/stylua"."2.0.2 lune".pkg_ref]
ref_ty = "pesde"
name = "pesde/stylua"
version = "2.0.2"
index_url = "https://github.com/pesde-pkg/index"
[graph."pesde/stylua"."2.0.2 lune".pkg_ref.dependencies]
core = [{ name = "pesde/toolchainlib", version = "^0.1.3", index = "https://github.com/daimond113/pesde-index", target = "lune" }, "standard"]
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
[graph."pesde/stylua"."2.0.2 lune".pkg_ref.target]
environment = "lune"
bin = "init.luau"
[graph."pesde/toolchainlib"."0.1.7 lune"]
resolved_ty = "standard"
[graph."pesde/toolchainlib"."0.1.7 lune".target]
environment = "lune"
lib = "src/init.luau"
[graph."pesde/toolchainlib"."0.1.7 lune".dependencies]
"jiwonz/dirs" = ["0.1.2 lune", "dirs"]
"jiwonz/pathfs" = ["0.1.0 lune", "pathfs"]
"lukadev_0/option" = ["1.2.0 lune", "option"]
"lukadev_0/result" = ["1.2.0 lune", "result"]
[graph."pesde/toolchainlib"."0.1.7 lune".pkg_ref]
ref_ty = "pesde"
name = "pesde/toolchainlib"
version = "0.1.7"
index_url = "https://github.com/daimond113/pesde-index"
[graph."pesde/toolchainlib"."0.1.7 lune".pkg_ref.dependencies]
dirs = [{ name = "jiwonz/dirs", version = "^0.1.1", index = "https://github.com/daimond113/pesde-index" }, "standard"]
option = [{ name = "lukadev_0/option", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
pathfs = [{ name = "jiwonz/pathfs", version = "^0.1.0", index = "https://github.com/daimond113/pesde-index" }, "standard"]
result = [{ name = "lukadev_0/result", version = "^1.2.0", index = "https://github.com/daimond113/pesde-index" }, "peer"]
[graph."pesde/toolchainlib"."0.1.7 lune".pkg_ref.target]
environment = "lune"
lib = "src/init.luau"

View file

@ -13,3 +13,6 @@ default = "https://github.com/pesde-pkg/index"
[dependencies]
result = { name = "lukadev_0/result", version = "^1.2.0" }
[dev_dependencies]
stylua = { name = "pesde/stylua", version = "^2.0.2", target = "lune" }