fobject:read() now supports reading until a specific character
This commit is contained in:
parent
bba92a74f9
commit
1f66ef4f1c
@ -42,6 +42,16 @@ local function fread(self,length)
|
|||||||
rstr = rstr .. lstr
|
rstr = rstr .. lstr
|
||||||
until rstr:len() == length or lstr == ""
|
until rstr:len() == length or lstr == ""
|
||||||
return rstr
|
return rstr
|
||||||
|
elseif type(length) == "string" then
|
||||||
|
local buf = ""
|
||||||
|
if length == "*l" then
|
||||||
|
length = "\n"
|
||||||
|
end
|
||||||
|
repeat
|
||||||
|
local rb = fsmounts[self.fs].read(self.fid,1) or ""
|
||||||
|
buf = buf .. rb
|
||||||
|
until buf:match(length) or rb == ""
|
||||||
|
return buf:match("(.*)"..length)
|
||||||
end
|
end
|
||||||
return fsmounts[self.fs].read(self.fid,length)
|
return fsmounts[self.fs].read(self.fid,length)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user