From eaa4eb7d86bffc82d85c74db06757beed7c0938f Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 14:28:15 +0000 Subject: [PATCH] FS library updates --- modules/library/fs-std.lua | 8 ++++++++ modules/library/fs-util.lua | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) 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