lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 04.10.2015 um 07:21 schröbte Paul K:
Hi All,

Hi!


I saw a discussion some time ago on making file seek/tell to work with
large (>2GB) files on Windows 32bit:
http://lua-users.org/lists/lua-l/2015-05/msg00370.html

I used Roberto's suggestion, but modified it slightly as the linker
couldn't find fseeko and ftello (I replaced them with fseeko64 and
ftello64):

#if defined(liolib_c) && defined(__MINGW32__)
#include <sys/types.h>
#define l_fseek(f,o,w) fseeko64(f,o,w)
#define l_ftell(f) ftello64(f)
#define l_seeknum off_t

You should use `off64_t` here instead. `off_t` is typedefed as `long` which is 32 bit on Windows.

#endif

I compiled Lua 5.3.1 with mingw 4.8.1 and everything has been working
as expected, but I only tested it on one machine. Is it the right way
to apply this fix?

I initially was confused by the message from f:seek("end"), which
returned (on a large file):

nil    "Invalid argument"    22

f:seek("set", -1) returned the same result. I think it's a bit
misleading as there is nothing wrong with the arguments I passed.

Works fine here! Maybe your lua.exe is picking up the wrong DLL?!


Paul.


Philipp