File: ex5.lua

package info (click to toggle)
luasocket 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,264 kB
  • sloc: ansic: 4,845; makefile: 337; sh: 116
file content (15 lines) | stat: -rw-r--r-- 328 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function source.empty(err)
  return function()
    return nil, err
  end
end

function source.file(handle, io_err)
  if handle then
    return function()
      local chunk = handle:read(20)
      if not chunk then handle:close() end
      return chunk
    end
  else return source.empty(io_err or "unable to open file") end
end