removed unarchive from the mtar library, wasn't meant to be in there anyway

This commit is contained in:
Izaya 2020-06-25 09:33:22 +10:00
parent 22bd6982d0
commit f0fb5ff776

View File

@ -1,24 +1,5 @@
local mtar = {} local mtar = {}
-- detect OS hopefully
if _OSVERSION then
if _OSVERSION:sub(1,8) == "OpenOS" then
OPENOS = true
elseif _OSVERSION:sub(1,9) == "PsychOS" then
PSYCHOS = true
end
else
LINUX = true
end
local function mkdir(dir)
if OPENOS or LINUX then
os.execute("mkdir "..dest.."/"..dir.." &> /dev/null")
elseif PSYCHOS then
-- todo: write PsychOS support
end
end
local function toint(s) local function toint(s)
local n = 0 local n = 0
local i = 1 local i = 1
@ -74,39 +55,4 @@ function mtar.iter(stream) -- table -- function -- Given buffer *stream*, return
end end
end end
function mtar.unarchive(stream,dest,verbose) -- Extract mtar archive read from *stream* to *dest*. If *verbose*, print status.
dest = dest or "."
while true do
local nlen = toint(stream:read(2) or "\0\0")
if nlen == 0 then
break
end
local name = cleanPath(stream:read(nlen))
local fsize = toint(stream:read(2))
if verbose then
io.write(name.." "..tostring(fsize).."... ")
end
local dir = name:match("(.+)/.*%.?.+")
if (dir) then
mkdir(dir)
end
local f = io.open(dest.."/"..name,"wb")
local rsize,buf = fsize, ""
if f then
repeat
buf = stream:read(math.min(rsize,2048))
f:write(buf)
rsize = rsize - buf:len()
if verbose then
io.write(tostring(rsize).." ")
end
until rsize <= 1
f:close()
end
if verbose then
print("done.")
end
end
end
return mtar return mtar