Todor Totev | 30 Sep 18:59
Favicon

How to change io::f_seek to use 64 bit numbers

Hi all,
I'd like to use (platform specific) fseek with 64-bit file offsets inside  
io lib f_seek function.
But it gets the lua number with luaL_optlong which truncates it to long.
What do you suggest me to fix it?
Kind regards,
Todor

Shmuel Zeigerman | 1 Oct 11:00

Re: How to change io::f_seek to use 64 bit numbers

Todor Totev wrote:
> I'd like to use (platform specific) fseek with 64-bit file offsets 
> inside io lib f_seek function.
> But it gets the lua number with luaL_optlong which truncates it to long.
> What do you suggest me to fix it?

Either patch Lua with your platform-specific fseek, or write a library.

Use luaL_optnumber rather than luaL_optlong, cast it to whatever is a 
64-bit integer type on your platform, then you'll be able to get/set 
offsets up to 2^53 bytes (assuming lua_Number is double).

--

-- 
Shmuel

Todor Totev | 2 Oct 15:56
Favicon

Re: How to change io::f_seek to use 64 bit numbers

On Wed, 01 Oct 2008 12:00:33 +0300, Shmuel Zeigerman <shmuz <at> 013net.net>  
wrote:

> Todor Totev wrote:
>> I'd like to use (platform specific) fseek with 64-bit file offsets  
>> inside io lib f_seek function.
>> But it gets the lua number with luaL_optlong which truncates it to long.
>> What do you suggest me to fix it?
>
> Either patch Lua with your platform-specific fseek, or write a library.
>
> Use luaL_optnumber rather than luaL_optlong, cast it to whatever is a  
> 64-bit integer type on your platform, then you'll be able to get/set  
> offsets up to 2^53 bytes (assuming lua_Number is double).
>

luaL_optnumber is what I need, thank you very much.


Gmane