lua-users home
lua-l archive

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


malkia <malkia@gmail.com> wrote:
> 
> Thank you for the information. I saw that fpos_t is int64 anywhere
> (32-bit, 64-bit), which is great news.
> I wonder how I skipped that function (I've never even heard about it -
> fsetpos/fgetpos).
> 
> Gotta try it on XP whether it works.

Well, it works here. I basically use the same method to link against
MSVCRT.DLL as you do (ie linking with msvcrt_win2000.obj) and so far,
these functions do the job. (Though I readily admit that most files I
work with are smaller than 4gb. But all the 4gb+ tests I did were OK.)

If you find problems with that approach, it'd be nice if you reported
back.

-- 
cheers  thomasl

> 
> On Fri, Aug 5, 2011 at 3:06 AM, Thomas Lauer <thomas.lauer@virgin.net> wrote:
> > Dimiter 'malkia' Stanev <malkia@gmail.com> wrote:
> >
> >> > 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.
> >
> > I was trying to do the same (ie linking LuaJIT2 with MSVCRT.DLL) and I
> > solved this specific problem via the CRT functions fgetpos() and
> > fsetpos(). Have a look at these; as far as I can tell they do work with
> > streams, so it should be possible to implement a local variant of
> > fseek() with them.
> >
> > --
> > cheers  thomasl
> >
> >
> >