Skip to content

Commit 4aa7772

Browse files
committed
Removed single use helper functions from unzip.
1 parent 7d6a6a0 commit 4aa7772

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

arch/UNZIP.LUA

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,8 @@ function unzip(p)
3333
-- C = read chunk size
3434
-- f = file
3535
local C, f = 4096
36-
3736
f, E = io.open(p, "rb") D()
3837

39-
-- R = read bytes
40-
local function R(n)
41-
local s, E = f:read(n) D()
42-
return s
43-
end
44-
45-
local function S(n) f:seek("cur", n) end
46-
4738
while true do
4839

4940
-- s = Signature
@@ -63,15 +54,15 @@ function unzip(p)
6354
if not s or #s < 30 or not s:find("^PK\3\4") then break end
6455
v, fl, cm, _, _, ec, cs, us, nl, el = string.unpack("<HHHHHIIIHH", s, 5)
6556

66-
fn, E = R(nl) D() -- filename
67-
if el > 0 then S(el) end
57+
fn, E = f:read(nl) D() -- read the filename
58+
if el > 0 then f:seek("cur", el) end
6859

6960
print("Extracting: " .. fn)
7061

7162
re = cs
7263

7364
---Read compressed data in chunks
74-
local function RC()
65+
local function R()
7566
if re <= 0 then return nil end
7667

7768
-- c = chunk
@@ -99,11 +90,11 @@ function unzip(p)
9990

10091
if cm == 0 then -- uncompressed file
10192
while re > 0 do
102-
local c = RC()
93+
local c = R()
10394
if c then W(c) else break end
10495
end
10596
elseif (cm == 8 or cm == 9) and pcall(require, "INFLATE") then -- deflated file
106-
inflate(RC, W, cm == 9)
97+
inflate(R, W, cm == 9)
10798
else
10899
print("!Unsupported compression method " .. cm)
109100
end

0 commit comments

Comments
 (0)