lua-users home
lua-l archive

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


Would be acceptable to include a workaround so that one could enable
support for such large files (someone mentioned fseek64) just using an
option in luaconf.h, say #define USE_FSEEK64?

LuaJIT has support for 64-bit seeks.

#if LJ_TARGET_POSIX
  res = fseeko(fp, ofs, opt);
#elif _MSC_VER >= 1400
  res = _fseeki64(fp, ofs, opt);
#elif defined(__MINGW32__)
  res = fseeko64(fp, ofs, opt);
#else
  res = fseek(fp, (long)ofs, opt);
#endif
  if (res)
    return io_pushresult(L, 0, NULL);
#if LJ_TARGET_POSIX
  ofs = ftello(fp);
#elif _MSC_VER >= 1400
  ofs = _ftelli64(fp);
#elif defined(__MINGW32__)
  ofs = ftello64(fp);
#else
  ofs = (int64_t)ftell(fp);
#endif

Actually I had to disable that for my library builds for Windows as I want to link with MSVCRT.DLL and XP's MSVCRT.DLL (not MSVCR80, MSVCR90, etc.) does not have _ftelli64 (or was it _fseeki64), and although there is _telli64 (or _seeki64) it cannot be reused for file-handles through the means of fileno() because it would differ and it's just not safe.

But the point is, what I did is normally not needed, so LuaJIT solution, although not being I guess fully ANSI C compliant works.