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

38 lines
530 B
Lua
Raw Normal View History

hT = {["_c"]=0}
function fopen(p,m)
local d,p = fres(p)
2017-04-23 19:05:16 +10:00
local f,C=d.open(p,m),hT._c
if f then
2017-04-23 19:05:16 +10:00
hT._c = C + 1
hT[C] = {d,f}
return C
end
return false
end
function fclose(h)
if hT[h] then
hT[h][1].close(hT[h][2])
end
return false
end
function fread(h,n)
if hT[h] then
return hT[h][1].read(hT[h][2],n)
end
return false
end
2017-06-13 00:28:15 +10:00
function freadall(f)
local s=""
repeat
c=fread(f,2048)
s=s..c
until c==""
return s
end
function fwrite(h,d)
if hT[h] then
return hT[h][1].write(hT[h][2],d)
end
return false
end