diff --git a/modules/library/fs-std.lua b/modules/library/fs-std.lua index 5fec249..8988f32 100644 --- a/modules/library/fs-std.lua +++ b/modules/library/fs-std.lua @@ -21,6 +21,14 @@ function fread(h,n) end return false end +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) diff --git a/modules/library/fs-util.lua b/modules/library/fs-util.lua index 2ab6bc5..408b0ce 100644 --- a/modules/library/fs-util.lua +++ b/modules/library/fs-util.lua @@ -17,14 +17,9 @@ function fmove(i,o) frm(i) end function fload(i) - local f,s = fopen(i,"rb"),"" + local f = fopen(i,"rb") if f then - local c=fread(f,math.huge) - repeat - s=s..c - c=fread(f,math.huge) - until c == nil - return load(s) + return load(freadall(f)) end return false end