removed unarchive from the mtar library, wasn't meant to be in there anyway
This commit is contained in:
parent
22bd6982d0
commit
f0fb5ff776
@ -1,24 +1,5 @@
|
||||
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 n = 0
|
||||
local i = 1
|
||||
@ -74,39 +55,4 @@ function mtar.iter(stream) -- table -- function -- Given buffer *stream*, return
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user