- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreader.lua
More file actions
Latest commit
29 lines (26 loc) · 620 Bytes
/
Copy pathreader.lua
File metadata and controls
29 lines (26 loc) · 620 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
localstrsub=string.sub
localfunctionnew_string_reader(src)
localpos=1
localfunctionreader()
localchunk=strsub(src, pos, pos+4096-32)
pos=pos+#chunk
return#chunk>0andchunkornil
end
returnreader
end
localfunctionnew_file_reader(filename)
localf
iffilenamethen
f=assert(io.open(filename, 'r'), "cannot open file " ..filename)
else
f=io.stdin
end
localfunctionreader()
returnf:read(4096-32)
end
returnreader
end
return {
string=new_string_reader,
file=new_file_reader,
}