The problem is not in io.open , but in file:seek . You can check this error as follows:
filesize, err = file:seek("end") if not filesize then print(err) end
The error message is probably an Invalid argument . This is due to the fact that for files larger than 2 GB its size exceeds what a 32-bit long can contain, which makes the C fseek function fseek .
On POSIX systems, Lua uses fseeko , which takes the size off_t instead of long in fseek . There is _fseeki64 Windows, which I think does a similar job. If they are not available, fseek used and this will cause a problem.
The corresponding source is liolib.c (Lua 5.2). As @lhf points out, fseek ( source ) is always used in Lua 5.1. Upgrading to Lua 5.2 could solve the problem.
source share