OC-MultICE/modules/library/fs-util.lua

31 lines
467 B
Lua

function fcopy(i,o)
local f1,f2 = fopen(i,"rb"),fopen(o,"wb")
if f1 and f2 then
local c=fread(f1,math.huge)
repeat
fwrite(f2,c)
c=fread(f1,math.huge)
until c == nil
fclose(f1)
fclose(f2)
return true
end
return false
end
function fmove(i,o)
fcopy(i,o)
frm(i)
end
function fload(i)
local f,s = fopen(i,"rb"),""
if f then
local c=fread(f,math.huge)
repeat
s=s..c
c=fread(f,math.huge)
until c == nil
load(s)
end
return false
end